Make a continuous line from an edge
3 views (last 30 days)
Show older comments
Francesco Pignatelli
on 26 Jul 2022
Commented: Francesco Pignatelli
on 26 Jul 2022
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1077585/image.png)
0 Comments
Accepted Answer
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
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!