Tracking a segmented line in grayscale images
2 views (last 30 days)
Show older comments
Hi guys
I Need to trace a line following the profile of alternated dark-light ( D-L)structures to calculate these lines' roughness. I have a stack of (D-L)*n profiles and I want to draw a line at the middle of L layers, following the profile. I Aldo Need to store line data for further analysis.
Any suggestion Is warmly welcome.
Cheers
2 Comments
KALYAN ACHARJYA
on 2 Feb 2021
Marco's Comment moved here
Hi Darova,
thanks for the reply.
Here it is. This image is not that good but it is the only i currently have with me and it can work as an example. I need to track a single line for each bright section (or dark section, it is not important which). This line is not straight but should follow the section profile, with asperities. These data should be also stored for further analysis.

Answers (1)
KALYAN ACHARJYA
on 2 Feb 2021
Edited: KALYAN ACHARJYA
on 2 Feb 2021
One way
grayImage=rgb2gray(imread('image_track.png'));
bw_im=imbinarize(grayImage,0.6);
subplot(121),imshow(bw_im);
bw_im=bwareaopen(bw_im,20);
bw_im=~bwareaopen(~bw_im,20);
row_data=find(all(bw_im==1,2))
grayImage(row_data,:)=255;
subplot(122),,imshow(grayImage);
You can modify more to get the desired results

0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!