How do I get the brightest pixels from this image?

3 ビュー (過去 30 日間)
Alexander Moody
Alexander Moody 2023 年 10 月 3 日
コメント済み: Alexander Moody 2023 年 10 月 4 日
The image in question is above. I want to get the pixel values of the bright ring that lines the center of this uneven ring.
This was a binary image (kind of an uneven donut), then I did the distance transform of the image. What you see is the result.
There is a ridge along the middle of the donut that contains the brightest pixels (farthest from edge). I want to algorithmically obtain all of those pixel values or the locations in the image where those pixel values are.
Suggestions are welcome. I do not need a fully coded solution... unless you want a coding challenge.

採用された回答

Image Analyst
Image Analyst 2023 年 10 月 3 日
編集済み: Image Analyst 2023 年 10 月 4 日
You should be able to use @bwskel to get the skeleton. Then use the skeleton as a mask to get the pixel values along the ridge. See attached example where I get the mean width by examining along the spine of the distance transform. If you wanted the pixel intensities instead of the diameters, you'd do
skelImage = bwskel(mask); % Get skeleton of the binary image (not the distance transform).
% Get 1-D vector of all the pixel intensities in the original image along the mask spine.
pixelSkelValues = grayImage(skelImage);
  1 件のコメント
Alexander Moody
Alexander Moody 2023 年 10 月 4 日
Excellent answer! Simple and very effective. Thank you!
I already tried it and it works really well. I forgot about bwskel() function because I never have a use for it.

サインインしてコメントする。

その他の回答 (1 件)

DGM
DGM 2023 年 10 月 3 日
編集済み: DGM 2023 年 10 月 3 日
See watershed()
% assuming D is a distance map
D = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1500965/image.png');
D = im2gray(D);
% find the ridgeline
mask = ~watershed(D);
% visualize both
imshow(imfuse(mask,mat2gray(D)),'border','tight')
xlim([450 1280]) % zoom in so it's visible in the forum
ylim([550 1350])
% get the distance at the ridgeline (the local width)
Dridge = D(mask);
For most tasks, the mask can be used directly instead of trying to use subscripts. If you need subscripts for geometric purposes, use find().
This example has a different end goal, but it demonstrates the process of addressing image pixels using three different appcoaches: a mask, linear indices derived from the mask, and row/column subscripts derived from the mask.
That should serve to substantiate my recommendation to use the mask alone for addressing tasks.
  1 件のコメント
Alexander Moody
Alexander Moody 2023 年 10 月 4 日
You know, I was thinking about using a watershed, but the problem is that it doesn't capture the whole ring. This is a great answer though. I really appreciate your help. Thank you!

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by