join close lines in one thicker

조회 수: 3 (최근 30일)
5mid
5mid 2017년 11월 19일
댓글: prasanth s 2018년 12월 4일
I have this image
How could I close the borders with just one continuous line? To something like this
Thank you

답변 (2개)

Image Analyst
Image Analyst 2017년 11월 19일
Take the coordinates of the green lines and burn them into a binary image. See attached demo and adapt it.
Then use imclose() to enlarge and blend them into a bigger connected mass.
binaryImage = imclose(binaryImage, ones(9));
Then use bwareafilt() to extract out the largest blob:
binaryImage = bwareafilt(binaryImage, 1);
Then blacken the image where the white pixels are
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRgbImage = bsxfun(@times, rgbImage, cast(~binaryImage, 'like', rgbImage));
  댓글 수: 2
5mid
5mid 2017년 11월 19일
Yes this is working for few lines, imline function is really slow. I have around 4k of lines to process. The image that I showed is just a cut.
Image Analyst
Image Analyst 2017년 11월 19일
Maybe try calling plot() onto the image, then use getframe() to get the frame (though it might not be the same size anymore) and find the pure green pixels, then use imclose(). Might be a lot faster.

댓글을 달려면 로그인하십시오.


prasanth s
prasanth s 2018년 12월 3일
why matlab did not have functions to draw and burn basic shapes (line, triange,..) in image.i did not find any file exchange also.
  댓글 수: 2
Image Analyst
Image Analyst 2018년 12월 3일
It does. See attached demos.
If you have the Computer Vision System Toolbox, you can also use insertShape().
prasanth s
prasanth s 2018년 12월 4일
Thanks...insertShape() thats what i needed.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by