find the certain region in image
조회 수: 4 (최근 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167991/image.jpeg)
However, if the top tip is attached to one of the regions then I want to ignore that image and do nothing.Like this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167992/image.jpeg)
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!