find the certain region in image

3 views (last 30 days)
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 Comments
Image Analyst
Image Analyst on 12 Jul 2018
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
Arsalan Akbar on 16 Jul 2018
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

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 8 Oct 2017
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.

More Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!