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!!

回答(1 个)

Image Analyst
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 个评论
Varshini Guddanti
Varshini Guddanti 2016-9-23
I cannot attach the image due to privacy issues.
My image is actually 8-bit uint8 green-black image [0 255][black green](if I'm saying it right!). But when I tried to display that image I only get a gray image but not my green one.
But, when I applied thresholding to my grayimage, my image got more disturbed.
Image Analyst
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by