RSS
 

Archive for the ‘OpenCV’ Category

OpenCV: Image range from [0...255] to [0...1]

21 Oct

Some time we need the image to be in some special range to be useful for some algorithm. In this case I needed my image to be in [0...1] range. I found this helpful piece of code, I tried it and I wanted to share it.

//read in a image
//this will result in a 8bit image [0...255]
IplImage* image_8U = cvLoadImage("test.jpg");

//to change the bit-depth you will have to allocate new memory
IplImage* image_32F = cvCreateImage(cvGetSize(image_8U),IPL_DEPTH_32F,image_8U->nChannels);

//now convert the 8bit Image into 32bit floating points
cvCvtScale(image_8U,image_32F);

//now all your data is stored in float values but in the original scale [0...255]
//to change this you'll have to normalize your matrix

// this will result in an image that is scaled to [0...1] by dividing through the highest value in the array
cvNormalize(image_32F,image32_F,0,1,CV_MINMAX);

[ad#AdBrite inline]

 
No Comments

Posted in OpenCV

 

OpenCV: Qt and OepnCV Development Tips

21 Oct

1 – Makefiles and others, that’s are used by the make tool, are generated by building systems. In particular, Qt uses qmake and OpenCV, cmake. And I like more CMake, because are more projects that’s use, then you can give some help and tips easily. Qt Creator supports CMake. More: www.cmake.org

2 – If you include some header from some lib, you needs to link against this lib. An example, you was included highgui.h but not linked against the libhighgui. Another common mistake: you link your program to a lib A that’s
are linked with lib B, and don’t link against B. You’ll probably got a lot of undefined symbols too, since lib A needs things are in B, but you aren’t linking against B.

 
No Comments

Posted in OpenCV

 

OpenCV: Older versions

21 Oct

You can download older version of OpenCV using this link.

Of course, obsolete versions are also there.

 
No Comments

Posted in OpenCV

 

OpenCV: Difference between cvCloneImage and cvClone

29 Aug

As of my experience,
- cvClone makes a copy of the image with respect to the ROI attached.
- cvCloneImage makes a full clone of the image (e.g., a duplicate full size image with its own matching ROI attached) rather than just copying the sub-image identified by the source ROI.
[ad#AdBrite inline]

 
No Comments

Posted in OpenCV

 

OpenCV: Access RGB value of an image

29 Aug

[ad#AdBrite inline]

CvScalar p = cvGet2D(img, y, x);
unsigned char r = p.val[0];
unsigned char g = p.val[1];
unsigned char b = p.val[2];

[ad#AdBrite inline]

 
No Comments

Posted in OpenCV