Segmenting objects from a threshold image
1 回表示 (過去 30 日間)
古いコメントを表示
I have thresholded an image using thresholder app in Matlab and converted the output for an image to black and white. AS a result I got the following output,

Now what I need to do is to isolate the specific type of square in the thresholded image from above image: I want my output to be as follows

I have tried bwareafilt(mask, [minArea maxArea]); command but that dosen't give optimal solution, more on that is here https://www.mathworks.com/matlabcentral/answers/676728-how-to-implement-helping-functions-for-counting-lego-blocks-in-image
Please follow comment section in above link to understand the problem of using bwareafilt command.
Is there anyone who knows solution for how to tackle this problem.
Thank You in anticipation.
3 件のコメント
採用された回答
Image Analyst
2020 年 12 月 5 日
"Based on the size, I want the smallest blob's count" <== If by count you mean area in pixels of the smallest blob in the segmented image, you can do this:
smallestBlob = bwareafilt(maskBlue, 1, 'smallest');
areaInPixels = nnz(smallestBlob)
3 件のコメント
Image Analyst
2020 年 12 月 5 日
With an image that is millions of pixels, it's highly unlikely that you will have two blobs with the same area. If you see that happening, I'd like to see the original image and mask image. However there is a way to do it.
% Measure areas of all blobs:
props = regionprops(mask, 'Area')
% Get all the areas into a double vector
allAreas = [props.Area];
% Find the smallest area, in pixels.
minArea = min(allAreas)
% Count the number of blobs that have the minArea exactly.
blobCount = sum(allAreas == minArea) % Will be 1 in almost every case unless you've synthetically created an image with known areas.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
