How to do image segmentation of a beam?

2 ビュー (過去 30 日間)
U B
U B 2023 年 9 月 5 日
コメント済み: Image Analyst 2023 年 9 月 7 日
How to use image segmentation to select the whole light beam?
My final aim is to select the whole beam using image segmentation and then calcuate the minimum intensity point (center here but not necessary in other images) and plot it in an XY cartesian cordinate plane.
  9 件のコメント
U B
U B 2023 年 9 月 7 日
About the colormap I was using before, it was not an inbuilt colormap. We customised it with certain value of color for our need. We call it RainbowColormap256.
Image Analyst
Image Analyst 2023 年 9 月 7 日
Uh, thanks. But why couldn't you attach the original gray scale (non-colorized) image? That would save us the trouble of having to undo the colormap.

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

回答 (1 件)

DGM
DGM 2023 年 9 月 7 日
編集済み: DGM 2023 年 9 月 7 日
Oog. I'm answering with gloves on, so this is hasty.
First, a preliminary solution:
% we should be working with 2D data, not RGB
[inpict,map] = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1475201/88.bmp');
% map is close, but not quite exactly the same as hot(256);
% dunno what's going on there or why
% going to treat the index array as a grayscale image (again, not a good idea)
% after this point, we're working with 2D grayscale data.
% that's where we should be starting in practice.
inpict = mat2gray(inpict);
% assume that the bg is a minimal region
% assume that the bg is connected to the image boundary,
% but not connected to the interior minima
bgmask = inpict == inpict(1,1); % find the background
% i'm assuming that the interior minima are always
% exactly the same value as the exterior minima
% so re-find the minima only within the fg region
bgmask = imclearborder(bgmask);
% get the centroids of the interior minima
S = regionprops(bgmask,'centroid');
C = vertcat(S.Centroid);
% display the things
imshow(inpict); hold on
plot(C(:,1),C(:,2),'x','linewidth',2)
Two things:
We still don't want to work with colormapped (pseudocolor) images. The colormapping is a tool for human visualization, but it's not helpful for the actual programmatic processing of the image. The images we should be working with are simple 2D grayscale data. They might be on some arbitrary scale, and they might not be stored in what we might consider an "image file" format, but conceptually, they're just 2D data.
Second (and this is entirely optional and inconsequential to the solution), could you attach the .m file used to generate said colormap?

カテゴリ

Help Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by