Archive Video Episode

Xvid
Mov

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//Included libraries. Some needed some not.
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "cv.h"
#include "highgui.h"
 
int main(void)
{
/*-----Declare variables-----*/
//Images
IplImage* pictureOne;
IplImage* pictureTwo;
IplImage* pictureResult;
 
//for loop variables
int i,j;
 
//Load the images
pictureOne = cvLoadImage("pic1.png",1);
pictureTwo = cvLoadImage("pic2.png",1);
 
//Define the size of the resulting image
pictureResult = cvCreateImage(cvSize(pictureOne->width,pictureTwo->height),IPL_DEPTH_8U,3);
 
//Subtract images using two for loops
for(i=0;i<pictureOne->height;i++) for(j=0;j<pictureOne->width;j++)
{
  ((uchar *)(pictureResult->imageData + i*pictureResult->widthStep))[j*pictureResult->nChannels + 0]= abs(((uchar *)(pictureOne->imageData + i*pictureOne->widthStep))[j*pictureOne->nChannels + 0]-((uchar *)(pictureTwo->imageData + i*pictureTwo->widthStep))[j*pictureTwo->nChannels + 0]); // Blue
 
  ((uchar *)(pictureResult->imageData + i*pictureResult->widthStep))[j*pictureResult->nChannels + 1]= abs(((uchar *)(pictureOne->imageData + i*pictureOne->widthStep))[j*pictureOne->nChannels + 1]-((uchar *)(pictureTwo->imageData + i*pictureTwo->widthStep))[j*pictureTwo->nChannels + 1]); // Green
 
  ((uchar *)(pictureResult->imageData + i*pictureResult->widthStep))[j*pictureResult->nChannels + 2]= abs(((uchar *)(pictureOne->imageData + i*pictureOne->widthStep))[j*pictureOne->nChannels + 2]-((uchar *)(pictureTwo->imageData + i*pictureTwo->widthStep))[j*pictureTwo->nChannels + 2]); // Red
}
 
//openCv function to replace for loops.
//cvAbsDiff(pictureOne, pictureTwo, pictureResult);
 
//Create image windows
cvNamedWindow("Picture One", 1);
cvNamedWindow("Picture Two", 1);
cvNamedWindow("Picture Result", 1);
 
//Show images
cvShowImage("Picture One", pictureOne);
cvShowImage("Picture Two", pictureTwo);
cvShowImage("Picture Result", pictureResult);
 
//Wait for key press to close windows
cvWaitKey(0);
 
//Close Windows
cvDestroyWindow("Picture One");
cvDestroyWindow("Picture Two");
cvDestroyWindow("Picture Result");
 
//Release the memory allocated to the images
cvReleaseImage(&pictureOne);
cvReleaseImage(&pictureTwo);
cvReleaseImage(&pictureResult);
}