Archive

Archive for the ‘ImageProcessing’ Category

IPP, new version of OpenCV, cmake and all the mess

June 12, 2010 Leave a comment

After some long time, had to work on OpenCV and for the first time had to use the IPP. IPP is Intel’s high performance routines. They many of them, but I had to work on OpenCV one. http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-open-source-computer-vision-library-opencv-faq/

Download it, run it.

Follow these two links for installation help

Before we move ahead, let’s look at the new version of OpenCV. It’s install guide is here. They were recommending CMake, so tried it. Because we are using the IPP here also so carefully have to give the bin address.

The IPP it appears, by searching online,  not to work properly with OpenCV’s new version. Had actually some problem, but it was I think because IPP libraries access the OpenCv libraries and these libraries have their names changed. So copy pasted them and changed new names to old names. Compiled and viola it’s linking.

Well while putting it here, it looks everything is working fine but it took some time before i was able to solve that.

Some lessons actually commonsense things which one forgets the moment you need it most.

1) Every time you add the Environment variable, restart Visual Studio

2) Bad idea to copy paste your dll’s, set their location path in the Environment Variable path.

Advertisements

OpenCv; Small Code using Erode and Dilate

February 16, 2009 Leave a comment

Small Code that reads pbm image, convert it into 1 channel image. Erodes it, dilates it and shows them

#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include <iostream>
#include "BlobResult.h"
#include "blob.h"

#ifdef _EiC

#define WIN32

#endif

using namespace std;

void main(void){

IplImage *inputImage = cvLoadImage( "0584.pbm", 1 );

IplImage *gray = cvCreateImage( cvSize(inputImage->width,inputImage->height), 8, 1 );

cvCvtColor( inputImage, gray, CV_BGR2GRAY );

IplImage*img = inputImage;

inputImage = gray;

::cvReleaseImage(&img);

cvNamedWindow( "orig", 1 );

cvShowImage( "orig", inputImage );

IplImage *outputImage;

IplImage *outputImage2;

outputImage = cvCreateImage( cvSize( inputImage->width, inputImage->height ), IPL_DEPTH_8U, 1 );

outputImage2 = cvCreateImage( cvSize( inputImage->width, inputImage->height ), IPL_DEPTH_8U, 1 );

cvErode(inputImage, outputImage, 0, 1);

cvNamedWindow( "erode", 1 );

cvShowImage( "erode", outputImage );

cvDilate(outputImage, outputImage2, 0, 2);

cvNamedWindow( "dilate", 1 );

cvShowImage( "dilate", outputImage2 );

cvReleaseImage(&outputImage);

cvReleaseImage(&outputImage2);

cvWaitKey();

return;

}

Writing PPM image file in C++

November 20, 2008 Leave a comment

Following is the C++ code for writting the ppm image file

strtemp has file name,

fData is the pointer to the image data.

sprintf(strtemp,”%04d.ppm”,imageNo);
ofstream output(strtemp, ios::binary|ios::out);
if(!output){
cout << ” unable to open the output file “<< strtemp << endl;
}
else{
output << “P6″<< endl <<“# foreground “<<endl;
output << itoa(IWidth, strtemp, 10);
output << ” “;
output << itoa(IHeight, strtemp, 10);
output << endl;
output << itoa(255, strtemp, 10) << endl;
output.write( (char *)fData, IHeight*IWidth*3);
output.close();

};//end of else

Categories: C++, File-Handling, ImageProcessing Tags:

OpenCv IplImage how to clear or initialize the image to scalar

November 17, 2008 6 comments

just use the cvSet

e.g if img is the IplImage object pointer with 3 channels.

cvSet(img, cvScalar(0,0,0));

will set each and every pixel to zero.

Becarefull with the  channels and cvScalar used.