Home>

Hello everyone. I have a simple code that uses the lines using Skimage Threshold_minimum. Yes, perhaps this is not the perfect method. Nevertheless, on the resulting image, I need to highlight lines, in which the thickness is less than a certain pixel value. That is, I expect that by specifying the value of 3 pixels, part of the lines on the image will be deleted. Alternatively considered CV2.houghlines, but he draws only flat lines.

Code:

Import Matplotlib.pyplot AS PLT
Import CV2.
From Skimage.Filters Import Threshold_tsu, Threshold_mean, Threshold_minimum, try_all_threshold
# Load Image.
img= cv2.imread ('C: \\ Temp \\ Map.png', 0)
Thresh_min= Threshold_minimum (IMG)
binary_min= img >
 Thresh_min.
Fig, Axes= Plt.Subplots (NCols= 2, Figsize= (8, 3))
ax= axes.ravel ()
AX [0] .imshow (IMG, CMAP= PLT.cm.gray)
AX [0] .set_title ('Original')
AX [1] .imshow (Binary_min, CMAP= PLT.cm.gray)
AX [1] .set_title ('Thresholded (MIN)')
Plt.Show ()

Result picture

Try Morphological Operation Operations Opening /Closing

Alex Alex2021-05-27 15:10:01