Study of Opencv (three): the image of the use and operation of _ color space tra

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
The use of images and operation _ color space transformation
Last Edit 2013/12/9
This note to the main image manipulation functions of several commonly used. Because the version now reference data and past, but it has been good for the entry. Future will go to the c+ + version, after all, this is a foundation.~~~

1)Assign an image storage space in memory: IplImage*cvCreateImage(CvSize size,int depth,int channels);
Of course size: is expressed as the image distribution size, you can specify the size of the manual, such as cvSize (720480), can also be used
cvGetSize(const CvArr*)Function to obtain the size,
Depth: is the depth of the image data, IPL_DEPTH_8U etc.
Channels: said the number of channels

2)Load an image: IplImage* cvLoadImage( const char* filename, int flags=CV_LOAD_IMAGE_COLOR );

#Define CV_LOAD_IMAGE_UNCHANGED -1 said the original load

#Define CV_LOAD_IMAGE_GRAYSCALE 0 to load images into a single channel
#Define CV_LOAD_IMAGE_COLOR 1 to load images into 3 channel
When the flags<0, the image after loading path determined by the original channel
When flags=0, the image after loading channel is forced into a single channel
When the flags> 0, the image after loading channel is forced into the 3 channel

3)The color to the gray level: void cvCvtColor( const CvArr* src, CvArr* dst, int code )

4)If we want to make the transformed image preserved.: int cvSaveImage( const char* filename, const CvArr* image );

The following use a code to use these functions:
#include <cv.h>
int main()
	const char *filename="D:\\07Personal files\\headpicture.jpg";  //The specified path reading image
	const char *wndNameColor="OrginalPicture";                      //The window name: show the original image window
        const char *wndNamegray="grayPicture";                         //The window name: transform image display window

	IplImage *src_image=cvLoadImage(filename,CV_LOAD_IMAGE_COLOR); //Load the image

	IplImage *dst_mage=cvCreateImage(cvGetSize(src_image),src_image->depth,1);//The assignment of a new image space
	cvShowImage(wndNameColor,src_image);	//Display	
	cvWaitKey(0);                            //Waiting for input
	return 0;

If there are errors in the debugging process:

Win7, VS2008, OpenCV2.3.1: "the program cannot be started, because the computer is missing in the tbb_debug.dll. try to reinstall this


Method: download the tbb3.0, after decompression, the..\bin\ia32\vc9 find tbb_debug.dll copy it to the OpenCV directory in the..\OpenCV2.3.1\build\common\tbb\ia32\vc9 (Note: OpenCV2.3.1 is unzip, may was different, the default is openCV)

Recompile the program, try try, if not resolved, it may be omitted variable configuration environment, please check the environment variables (computer --> --> advanced system settings; properties; --> the system properties window (switch to the Advanced tab) --> environment variable) is equipped with the corresponding..\OpenCV2.3.1\build\common\tbb\ia32\vc9

A method of alternatives: if you do not want to download, can go to the OpenCV directory in the..\OpenCV2.3.1\build\common\tbb\ia32\vc9 find tbb.dll, copy and paste, then renamed tbb_debug.dll (ha ha, is a good method.)

Method two: in the method and the alternative methods to solve the case, can be tbb_debug.dll (document source a or its alternatives) are copied to the..\OpenCV2.3.1\build\x86\vc9\bin directory.

The solution

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Kaye at December 15, 2013 - 10:52 AM