Using bwdist distance transform
Show older comments
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]);

Accepted Answer
More Answers (1)
Image Analyst
on 20 Apr 2021
Edited: Image Analyst
on 20 Apr 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 Comment
Nikolas Roeske
on 21 Apr 2021
Categories
Find more on Region and Image Properties in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
