Using bwdist distance transform

I'm using the bwdist function to create an image that has a bright center and dim surroundings as seen in the picture below. However I want the reverse of this as well where the edges are bright and the center is dim. Do you have any advice or is there another function for this purpose.
img = imread('mask.bmp');
IM2 = imcomplement(img);
[D,idx] = bwdist(IM2,'chessboard');
color = cat(3,D,zeros(size(D)),zeros(size(D))); % changes the color of the image
RGB1 = repmat(rescale(D), [1 1 3]);

 Respuesta aceptada

Nikolas Roeske
Nikolas Roeske el 21 de Abr. de 2021

0 votos

Hi I figured out how to do it so I figuried I would post my solution code. The commented section works but its just very slow. To do this you just need an image or mask that you want to feed in.

Más respuestas (1)

Image Analyst
Image Analyst el 20 de Abr. de 2021
Editada: Image Analyst el 20 de Abr. de 2021
Try inverting the mask when you pass it in to bwdist().
[D2, idx] = bwdist(~IM2,'chessboard');
Attach 'mask.bmp' if you need more help. Be sure IM@ is of type logical, not uint8.

1 comentario

Nikolas Roeske
Nikolas Roeske el 21 de Abr. de 2021
Line 2 in the code above already inverts the matrix and if the code is inverted again you get an image which I have attached to this post. What I am trying to do is reveres the gradient seen in the original post so that the center is dim and the edges are bright. I have attached the maks I used it is just a square of known dimentions.

Iniciar sesión para comentar.

Preguntada:

el 20 de Abr. de 2021

Respondida:

el 21 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by