RSS

Create Negative Image using OpenCV

03 Feb

#include "stdafx.h"
#include<opencv\cv.h>
#include<opencv\cxcore.h>
#include<opencv\highgui.h>

int _tmain(int argc, _TCHAR* argv[])
{
IplImage *src = cvLoadImage("C:\\Users\\opencv3\\img\\opencv.png",1);
IplImage *dest = cvCloneImage(src);

cvNamedWindow("Original:",1);
cvShowImage("Original:",src);

cvNot(src,dest);//Create a negative image from source image
cvNamedWindow("Negative:",1);
cvShowImage("Negative:",dest);

cvWaitKey(0);

cvDestroyWindow("Original:");
cvReleaseImage(&src);
cvDestroyWindow("Negative:");
cvReleaseImage(&dest);
return 0;
}

An alternative method of creating clone image

IplImage *dest = cvCreateImage(cvSize(src->width,src->height),8,3);
Advertisements
 
Leave a comment

Posted by on February 3, 2013 in C

 

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: