
How to connect broken lines, but no enlarge line width?
조회 수: 5 (최근 30일)
이전 댓글 표시
I need to fill rectangle(run fill holes), but the broken lines in rectangle stop me to do this. due to the high density rectangles in figure, so I want to connect broken lines, but no enlarge line width. Could you help me?
I have tryed to do dilate/erode/open/close mask operations, but they all can't meet my request.
Before After


댓글 수: 0
채택된 답변
埃博拉酱
2025년 1월 25일
function Image=FixBroken(Image,GapSize)
try
Image=imread(Image);
catch ME
if ME.identifier~="MATLAB:imagesci:imread:badImageSourceDatatype"
ME.rethrow;
end
end
Image=imbinarize(rgb2gray(Image));
Image=imclose(Image, strel('line', GapSize, 0)) | imclose(Image, strel('line', GapSize, 90));

댓글 수: 0
추가 답변 (1개)
Image Analyst
2025년 1월 25일
Try this to completely fill the rectangle as you asked (untested - post before image separately if you want me to test it):
after = bwconvhull(before, 'union');
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!