Make a continuous line from an edge

5 views (last 30 days)
Hello all,
I am trying to extract the edge from a picture. However the resulting edge is disconnected and I do not know how to each single segment I have, making a continuous line. I am usign the following code:
image=load('imagePLIF.mat');
image=image.image;
imageB=image(:,170:1232);
BW = medfilt2(imageB,[5,5]);
BW = mat2gray(BW);
imagesc(BW)
BWmean = rescale(BW);
PLIF_gaussfilt = imguidedfilter(imgaussfilt(BWmean));
PLIF_sharpen = imsharpen(PLIF_gaussfilt, 'Radius', 1, 'Amount', 1);
PLIF_sharpen(PLIF_sharpen > .12) = 1;
PLIF_edge = edge(PLIF_sharpen, 'Sobel');
figure()
imagesc(PLIF_edge)

Accepted Answer

sudobash
sudobash on 26 Jul 2022
Hey there!
So, as per my understanding, you want to make the edges continuous. I ran your code and found that it actually is giving the output as a single continuous line. When looking at the scaled down version, it looks as if the line is not continuous. Try opening the image in a window.
If you would like to have the line a bit more thicker, try using the 'nothining' option in sobel filter like this:
PLIF_edge = edge(PLIF_sharpen, 'Sobel','nothinning');
This gives thicker lines. I hope this answer helps solve your issue.
  3 Comments
Image Analyst
Image Analyst on 26 Jul 2022
Run bwskel after that. I would have thought edge() would do that internally and if it did, it shouldn't breaks the lines, but you say it did, so go figure. Anyway, I'd try bwskel() after the thick edge call and hopefully that won't break the lines. Otherwise if it does we need to do what I said in your comment in the other question - get the edges another way, like via thresholding and bwboundaries. However you didn't attach your original image here like I asked over there.
Francesco Pignatelli
Francesco Pignatelli on 26 Jul 2022
Hi @Image Analyst, yes the picture is different because it is a different snapshot I picked up randomly from my set of data. I have run bwskel() and it is working. Thank you very much!
Now my code is the following:
image=load('imagePLIF.mat');
image=image.image;
imageB=image(:,170:1232);
BW = medfilt2(imageB,[5,5]);
BW = mat2gray(BW);
imagesc(BW)
BWmean = rescale(BW);
PLIF_gaussfilt = imguidedfilter(imgaussfilt(BWmean));
PLIF_sharpen = imsharpen(PLIF_gaussfilt, 'Radius', 1, 'Amount', 1);
PLIF_sharpen(PLIF_sharpen > .12) = 1;
PLIF_edge = edge(PLIF_sharpen, 'Sobel','nothinning');
PLIF_edge=bwskel(PLIF_edge);
figure()
imagesc(PLIF_edge)
and the results is:
which looks good. Since I need to make statistics, I was actually thinking to cut off the small bubbles like the ones in red circles:
and color the area within the yellow lines in yellow. Do you know how to do that?

Sign in to comment.

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!