Tracking a segmented line in grayscale images

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

Can you show the image?
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.

Sign in to comment.

Answers (1)

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

Categories

Products

Release

R2019b

Asked:

on 1 Feb 2021

Edited:

on 2 Feb 2021

Community Treasure Hunt

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

Start Hunting!