Selecting a region in an image
36 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I want to be able to select a part of an image and store it in MATLAB. Can anyone tell me how I can do that.
I want to be able to load it and select the circle and store its circumference. Can I do this in MATLAB?
Thanks.
NS
0 件のコメント
回答 (2 件)
Image Analyst
2011 年 7 月 9 日
It's pretty easy. Look at my color segmentation demos for how to pick out colors, and BlobsDemo for how to find perimeter and area. Basically it's this 1) separate the color channels into red, green, and blue. 3 lines.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
2) do logical operations on them to get just the red circle. 1 line.
3) call bwlabel or bwconncomp. 1 line.
[labeledImage numberOfBlobs] = bwlabel(binaryImage, 8);
4) call regionprops. 1 line.
blobMeasurements = regionprops(labeledImage, originalImage, 'Perimeter');
So in 6 lines you should have it. Write back if you still can't get it.
2 件のコメント
Image Analyst
2011 年 7 月 9 日
Those kind of images are always tough. You could try thresholding and then using imclose to close the gaps. Then bwlabel and regionprops to find circular shapes. Or you could try hough() to try to find the circles directly. Unless you have thousands of images your best bet might be to manually locate them with imellipse.
Sean de Wolski
2011 年 7 月 8 日
There is a demo for this in the documentation for the Image Processing Toolbox.
7 件のコメント
Nathan Greco
2011 年 7 月 8 日
Hm. That is pretty hard to discern "automatically" through code. Perhaps just manually selecting the image (using ginput with curve fitting, perhaps?) would suffice.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!