Hi,
I’m trying to separate my objects as shown in the picture. The problem is that using dilation (or erosion in the case of image with opposite background/foregroud) the objects doesn’t separate. Any suggestions?
I write here the code with the binarization and the dilate function.
def Img_binarization(img):
print("Processing Grayscale image:\n")
plt.imshow(img, cmap='gray', vmin=0, vmax=255)
plt.show()
# Otsu's thresholding
thresh, image = cv.threshold(img,0,255,cv.THRESH_BINARY+cv.THRESH_OTSU)
print("Threshold selected: %d \n" % thresh)
kernel=cv.getStructuringElement(cv.MORPH_RECT, (3,3))
image1=cv.dilate(image, kernel, 3)
print("Processed Binary image:")
plt.imshow(image1, cmap='gray', vmin=0, vmax=255)
plt.show()
return image1