English 中文(简体)
Shape detection in image processing
原标题:

I m working on detecting the shape of any object. I have a binary image where the background is in white and the foreground/object is in black. I need to detect the shape of the object in the foreground which is in black.

How can i do it? The shape may be of a man/car/box etc. Please help

最佳回答

I m not sure which is your final goal as amphetamachine said but a pretty common approach to detect shapes could be the use of cvFindContours which given a binary image and returns a set of CvContour (which in fact is a cvSeq). Binary image can be retrieved quite simple by thresholding the image (cvThreshold). Check out the contours.c example in the sample/ of opencv src directory. Check this link as well:

Noah (2009) opencv tutorial

this sample code will give you an general idea:

cvThreshold( g_gray, g_gray, g_thresh, 255, CV_THRESH_BINARY );
cvFindContours( g_gray, g_storage, &contours );
cvZero( g_gray );
if( contours ){
    cvDrawContours(
        g_gray,
        contours,
        cvScalarAll(255),
        cvScalarAll(255),
        100 );
}
cvShowImage( "Contours", g_gray );

Once you have an encoding of the contour you can use cvMatchShapes which take 2 contours and return a measure of similarity between these contours.

Hope this approach provide you a head start!

问题回答

For accurate shape detection you need to use haar detection or at the least K nearest neighbor. Haar detection can be very accurate, but it takes a long time to set up. K nearest neighbor is easier to set up but is not as accurate. Check out this youtube video. This guy is using KNN to detect different hand gestures. Notice that the comparison image is basically a black blob. The bad thing about KNN is that it is that it takes a lot more resources to run the program, but with haar detection, the major processing has already been done when you create the cascade xml files with haartraining.exe





相关问题
Resources for Image Recognition

I am looking for a recommendation for an introduction to image processing algorithms (face and shape recognition, etc.) and wondered if anyone had an good recommendations, either for books, ...

Good reference book for digital image processing? [closed]

I am learning digital image processing on my own and would like recomendations on good reference books. If you know of books to definately stay away from that would be useful as well. Thanks

Python Tesseract can t recognize this font

I have this image: I want to read it to a string using python, which I didn t think would be that hard. I came upon tesseract, and then a wrapper for python scripts using tesseract. So I started ...

What s the quickest way to parallelize code?

I have an image processing routine that I believe could be made very parallel very quickly. Each pixel needs to have roughly 2k operations done on it in a way that doesn t depend on the operations ...

Computing object statistics from the second central moments

I m currently working on writing a version of the MATLAB RegionProps function for GNU Octave. I have most of it implemented, but I m still struggling with the implementation of a few parts. I had ...

Viola-Jones face detection claims 180k features

I ve been implementing an adaptation of Viola-Jones face detection algorithm. The technique relies upon placing a subframe of 24x24 pixels within an image, and subsequently placing rectangular ...

热门标签