How to name the cubes or identify them on a image after dividing an image into cubes?
4 次查看(过去 30 天)
显示 更早的评论
I have a 8-bit tiff image(200x512) which I divided into cubes this way:
1) Make the midline(mid horizontal row) of the image by making the pixels in that row to black.
2) Draw such lines for every 14 rows from the midline till the bottom of image AND from the midline to the upper part of the image.So, now we get 13 pixels between each row.
3) Draw lines by making the pixels black vertically for every 14 pixel columns till the last column of the image.
Now, I have a image with cubes on it(like a grid). And I want to identify each cube so that I can delete the cubes which have black pixels greater than a threshold.
Can anyone help me out in identifying the cubes!!
0 个评论
回答(1 个)
Image Analyst
2016-9-23
Just threshold that image, label it, and call regionprops asking for the Euler number. The Euler number tells you how many holes there are in each region. Then get a vector saying which regions have more than some threshold number of holes and use ismember to extract them. It's pretty trivial.
labeledImage = bwlabel(grayImage > 0);
props = regionprops(labeledImage, 'EulerNumber');
allEulerNumbers = [props.EulerNumber];
badRegions = allEulerNumbers < ......whatever
badLabels = ismember(labeledImage, badRegions) > 0;
% Erase bad regions from gray scale image
grayImage(badLabels) = 0;
etc. Attach your lined image if you can't figure out how to complete it.
2 个评论
Image Analyst
2016-9-23
Then don't use your private image. Use one of the demo images that ships with MATLAB and post the lined version of that.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!