Sunday, February 3, 2013

Create Negative Image using OpenCV

[sourcecode language="cpp"]

#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;
}

[/sourcecode]

An alternative method of creating clone image

[sourcecode language="cpp"]IplImage *dest = cvCreateImage(cvSize(src->width,src->height),8,3);[/sourcecode]

No comments:

Post a Comment

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...