tailieunhanh - OpenCVTutorial - Part II

The first step after tablishing a working environment is to begin manipulating images .This tutorial will give an introduction to the usage of some bacsic functions | OpenCV Tutorial Part II Loading Images and Using Histograms 29 November 2005 Gavin S Page gsp8334@ Tasks The first step after establishing a working environment is to begin manipulating images. This tutorial will give an introduction to the usage of some basic functions. Steps Performed Load an Image Calculate Histogram Values Calculate Basic Statistics Using Histogram Information For explanations on any functions used here see the OpenCV documentat. Gavin S Page gsp8334@ Loading the Image //the name of the image being loaded char* imageName = ""; //Load the image and make sure that it loads correctly IplImage* im = cvLoadImage(imageName, -1); if( im == 0 ) { //Drop out if the image isn't found std::cerr Gavin S Page gsp8334@ Tasks The first step after establishing a working environment is to begin manipulating images. This tutorial will give an introduction to the usage of some basic functions. Steps Performed Load an Image Calculate Histogram Values Calculate Basic Statistics Using Histogram Information For explanations on any functions used here see the OpenCV documentat. Gavin S Page gsp8334@ Loading the Image //the name of the image being loaded char* imageName = ""; //Load the image and make sure that it loads correctly IplImage* im = cvLoadImage(imageName, -1); if( im == 0 ) { //Drop out if the image isn't found std::cerr Gavin S Page gsp8334@ Specifying a Working Region In order to work with a histogram the image will have to converted to a single plane. //Create a single planed image of the same size as the original IplImage* grayImage = cvCreateImage(cvSize(im->width,im->height), IPL_DEPTH_8U, 1); //convert the original image to gray cvCvtColor(im, grayImage, CV_BGR2GRAY); //create a rectangular area to evaluate CvRect rect = cvRect(0, 0, 500, 600 ); //apply the rectangle to the image and establish a region of interest cvSetImageROI(grayImage, rect); Create an Image of a Single Plane Create the Grayscale Image Convert the Image to Gray Specify a Rectangular Region of Interest (ROI) and apply it to the image The cvCvtColor function can be used to convert images to one of several color spaces. To restore the region of interest to the whole image the .

TÀI LIỆU LIÊN QUAN
TỪ KHÓA LIÊN QUAN