フィルターのクリア

How to extend lines in binary image?

6 ビュー (過去 30 日間)
Ilya Tcenov
Ilya Tcenov 2019 年 3 月 1 日
編集済み: DGM 2023 年 4 月 27 日
HI all,
I used an edge detector on a graysclae image and got a binary image that has many lines (lines are 1's and the background is 0's). Example is given bellow. I need to extend these lines, so that the intersections will devide the image to regions (marked in red).
I can use imdilate, but I dont want to make these lines thicker, I need to extend them. In some cases I need to extend these lines segnificantly, so imdilate cant do the job.
To conclude, I am looking for a way to extend binary lines (longer, not thicker) by a specified factor.
Thank you for your help.
Capture.JPG

回答 (2 件)

Image Analyst
Image Analyst 2019 年 3 月 1 日
Try imclose(). It does imdilate() followed by imerode() to shring it back to the original size.
  5 件のコメント
Dillon Hudson
Dillon Hudson 2023 年 4 月 8 日
I'm also looking for a solution to this problem. I'm looking for a way to connect the boundary of a line to the next closest line (not necessarily another boundary). Perhaps based on the rough direction the line was pointed i.e. take a boundary point and add to that line along the path it would take if it was lengthed. My lines are only a pixel wide (from edge detection) and span a number of angles and lengths.
The picture attached below is after one iteration of imclose with a square structuring element. Should I be using a different structuring element?
Something like this would be acceptable where the pink lines represent what I'd like to be white.
Image Analyst
Image Analyst 2023 年 4 月 27 日
@Dillon Hudson please start your own discussion thread for this. It is possible though not trivial. And where the lines extend to depends on the order of the lines you connected before. It's not a unique solution.

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


Víctor Llamas Martínez
Víctor Llamas Martínez 2023 年 4 月 27 日
編集済み: DGM 2023 年 4 月 27 日
Hello.
In my case I ussually have to join points and lines that are closed together and in the most of the cases this code helps me out
se = strel('disk',2);
bw = imclose(bw,se);
imshow(bw)
With this you create a disk around each point of your binnary image and you try to find close points that are not connected with it. There is an example:
In this figure the line that must be continius is in some points disconnected, but aplying those code lines everithing gets connected propertly:
Perhaps some artifacts can appear in your image but by tuning the disk radius i think you can archieve an acceptable result.

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by