Make a continuous line from an edge

6 ビュー (過去 30 日間)
Francesco Pignatelli
Francesco Pignatelli 2022 年 7 月 26 日
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)

採用された回答

sudobash
sudobash 2022 年 7 月 26 日
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 件のコメント
Image Analyst
Image Analyst 2022 年 7 月 26 日
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 2022 年 7 月 26 日
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?

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

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by