Thinning the outline of an image

8 visualizzazioni (ultimi 30 giorni)
Michael S
Michael S il 7 Dic 2018
Commentato: Michael S il 10 Dic 2018
Hi all,
I'm attempting to reduce the thickness of lines in an image systematically while keeping the skeleton of the figure the same. What this effectively comes down to is trimming the outer layer of pixels along the perimeter of the figure. Ultimately, I am trying to match the # of pixels between different images by thinning or thickening the lines that make up the figures while keeping the original size and shape of each figure the same.
I have played around with several functions such as bwboundaries, bwmorph ('skel', 'thin', 'remove', etc.) but I am pretty sure these functions are not the right ones to do the job that I want, or I am just using these functions the wrong way. I attached an example of what I am trying to accomplish featuring a BW image of the letter 'R' and one that I " thinned" crudely by hand. Thanks in advance!

Risposte (1)

Image Analyst
Image Analyst il 7 Dic 2018
Try
  1. Threshold the image
  2. Use bwmorph(bw, 'skel', inf)
  3. Take the Euclidean distance transform of #1 with bwdist.
  4. Multiply those two together.
  5. Determine the radius of your lines.
  6. Threshold the image in step 4 at that radius.
  3 Commenti
Image Analyst
Image Analyst il 10 Dic 2018
For 4
out = D .* bw;
For 5, finding out the radius, you can just take the mode of D, right?
Michael S
Michael S il 10 Dic 2018
Hm I'm not sure why the radius of the line would be the mode of D... but mode(D) = 0 in this case.
Am I applying the bwdist() function to the right image? You originally wrote to apply it to #1, but multithresh(I) outputs only the threshold value for the image, not a matrix of pixel values.
I am also confused on how to rethreshold even when I do find the appropriate radius.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by