To fatten lines in an image in MATLAB, we can use morphological dilation. This operation expands or thickens the foreground of an image, while preserving its overall shape.
Here is an example code to fatten lines in a binary image using dilation:
main.m413 chars18 lines
In this example, we first read the binary image using the imread
function. We then create a structuring element se
using the strel
function. In this case, we create a horizontal line of length 5 pixels.
Finally, we perform dilation on the binary image using the imdilate
function, passing in the binary image and the structuring element as arguments. The resulting image is stored in the dilatedImage
variable.
We then display the original and dilated images side by side using the subplot
and imshow
functions, and add titles to them using the title
function.
By changing the structuring element se
, we can adjust the amount of dilation applied to the image.
gistlibby LogSnag