I’m currently developing a project with Mammography and I’m trying to comprehend how I can segment an image into two sections: a searchable area (ROI) and a non-searchable area. The focus of this question is directed at only the underlying algorithm of the actual image analysis / processing. Most of the results from Google and Stack Overflow have yielded helpful pieces of information, but none of them explain the steps of image analysis / processing and why these steps are important and what exactly they’re each doing.
I’ve written a small code segment that takes an image, re-sizes the image, and ‘binarizes’ the image. (Below.) Is there any way that I can trace a line (Contour?) on my binary image, move this line to my original image, and use it as a guideline in having my algorithm determine searchable areas (ROI) from non-searchable areas? Is there a simpler way of doing this?
// ** Main ** //
int main( int argc, char** argv )
{
/// Load an image
src = cvLoadImage(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
// Create Dummy Image
Mat destination;
destination = cvCreateMat(3328/5, 4084/5, CV_32FC1);
resize(src, destination,cvSize(3328/5,4084/5),0,0);
src = destination;
/// Create a matrix of the same type and size as src (for dst)
dst.create( src.size(), src.type() );
/// Create a window
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
// Binarize the Image
threshold(src, dst, 128, 255,CV_THRESH_BINARY | CV_THRESH_OTSU);
// Show the Image
imshow( window_name, dst );
/// Wait until user exit program by pressing a key
waitKey(0);
return 0;
}
For clarification and reiteration, I’ve looked into quite a few tutorials and nothing has been of help for this, specifically. I would appreciate all the help I can get!
To find lines on a binarized image you need to use a recursive function, and create a second array the same size as the image that you can store data in. This is an example of code I have recently written to detect blobs in a binarized image (note, this is in C#, a little adaption such as using vector<> rather than list would be required).
First, analyze a pixel to see whether it is worth tracing/hasn’t been traced:
Then trace each blob:
You could adapt these easily to only search for straight lines( I don’t know whether you require circular lines). Then use intersection points of the lines to build up an object with known lines for edges.
Alternatively, you can use Hough Lines and Circles (available in OpenCV) to trace lines and circles on the image for you. This has the benefit of giving lines in any orientation, but it does not give end points of straight lines.