join close lines in one thicker
显示 更早的评论
I have this image

How could I close the borders with just one continuous line? To something like this

Thank you
回答(2 个)
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
2017-11-19
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
2018-12-3
0 个投票
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
2018-12-3
It does. See attached demos.
If you have the Computer Vision System Toolbox, you can also use insertShape().
prasanth s
2018-12-4
Thanks...insertShape() thats what i needed.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Category Classification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!