find the certain region in image
3 次查看(过去 30 天)
显示 更早的评论
i have a set of image database. I am providing two images for my query. I want to find the region marked in blue.
However, if the top tip is attached to one of the regions then I want to ignore that image and do nothing.Like this
Some thoughts: I can't use bwconnected components area for those two regions because there are images in DB where tip can be extreme left or right. In those cases, one area is very small and other will be large. That hole can be at different places in different imagesets.
3 个评论
Image Analyst
2018-7-12
Possibly not since he didn't mark my solution below as accepted. However I still think that my code below would have worked. Did you try it?
Arsalan Akbar
2018-7-16
No Sir, i have not tried it yet . You are using area filter which returns the biggest blobs but some times the information is missing and 4,5 or some time 6 blobs are in the images . in that case this code may not work fine . and may be that is why he is not using your code
采纳的回答
Image Analyst
2017-10-8
First I'd fill the blobs and call
binaryImage = bwareafilt(binaryImage, 3); % Extract 3 largest blobs.
Then I'd call it again to make sure it's not picking up a small speck, and to make sure if there are 3 blobs that they are of substantial size
binaryImage = bwareafilt(binaryImage, [100, inf]);
Replace 100 with some number that is the number of pixels just below the size you'd expect to the top blob. If, after that you have only two blobs, like you said, ignore that image. However if you have 3 blobs, you can continue. First get the 2 largest ones:
binaryImage = bwareafilt(binaryImage, 2); % Extract 2 largest blobs.
Then I'd get the horizontal profile so that I can identify where the black break in the middle is:
horizontalProfile = sum(binaryImage, 1);
plot(horizontalProfile , 'b-', 'LineWidth', 2);
grid on;
Find the centroid of the dark region
props = regionprops(horizontalProfile > 0, 'Centroid');
xCentroid = props.Centroid(1);
yCentroid = props.Centroid(2);
Now scan down line by line finding, by using the find() function, where is the edge of the blob to the left and the edge of the blob to the right. See if you can figure that out yourself.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!