I have a image such as below which has horizontal and vertical lines in the field of view. I want to segment the vertical line adjacent to the dark area such as in red below and vertical line in the intersection of the horizontal line(as seen in black).The full image has many such structiures. I want to stack all similar segmented structures within the fov (Average measuremnet of red and black) and display.I also want to measure the average x and y as shown below if the red line concaves at the max conving location in y.

 採用された回答

Matt J
Matt J 2025 年 9 月 11 日

0 投票

I=im2double(im2gray(imread('image.png')));
BW=imbinarize(I);
D=bwareaopen(abs(gradient(I))>0.06,20);
D=imclose(D,strel('disk',5));
black=(median(BW,2)>0);
red=~black;
L=D.*red+2*D.*black;
imshow(labeloverlay(I,L,Colormap=[1,0,0;0,0,0]));

6 件のコメント

Vivek
Vivek 2025 年 9 月 22 日
Matt, Have a follow up.How would I stack all the left segmented red edges and right edges (IN red) to understand the behaviour of the profile in the FOV.
Matt J
Matt J 2025 年 9 月 22 日
編集済み: Matt J 2025 年 9 月 22 日
If it is a "follow-up", does that mean the original question was resolved?
Aside from that, it's not clear to me what "stack" means here. The segmented regions will all be of different sizes, so there is no natural "stacking" of them that I can comprehend. You can certainly extract each of the red regions using,
regions=regionprops(red,'Image');
You can then separate them into left and right edges by doing,
N=numel(regions);
isLeft=false(N,1);
for i=1:N
tmp=mean(regions(i).Image,1);
isLeft(i)=tmp(1)<tmp(end);
end
redLeft=red(isLeft);
redRight=red(~isLeft);
Vivek
Vivek 2025 年 9 月 22 日
What I meant is I want to overlay all the left and right edges to get a visual idea of how the profile varies
Matt J
Matt J 2025 年 9 月 22 日
編集済み: Matt J 2025 年 9 月 22 日
But again, how will you "overlay" them when they are not all the same size? If you will crop them to a common size, what is to determine the boundaries of the cropped region?
Vivek
Vivek 2025 年 9 月 29 日
What I want is to crop an image such as the below with only features of the the same size . What I want to see is to overlay the shape of the left edges and right edges of the vertical lines next to datk regions and the place where horizontal line intersects v ertical line in black. IN the image below I would want to overlay only the three vertical segments in red and in black
Matt J
Matt J 2025 年 9 月 29 日
編集済み: Matt J 2025 年 9 月 29 日
Please illustrate by drawing one rectangle (e.g. with drawrectangle) on the example segmented image above, demarcating one of the regions that we will want to overlay on other regions.
As part of the illustration, please also show us how the positions of the different edges of the rectangle are selected.

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

その他の回答 (1 件)

Tim Jackman
Tim Jackman 2026 年 1 月 10 日

1 投票

You may want to consider using uicaliper:
The tool can be interactively or programmatically placed, and it detects edge gradients for applications that seem very similar to yours.

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

製品

リリース

R2019a

質問済み:

2025 年 9 月 11 日

回答済み:

2026 年 1 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by