I have a distance transformed image and I have to return an image in which each pixel is assigned a highest value in the neighbourhood using a 3x3 grid. How to do that?
I am not sure if morphological Dilution does the same job. In my case it return the same image.
# load the image, convert it to grayscale, and blur it slightly
image = cv2.imread(r'C:\Users\x\Desktop\sampleImg\ecu.tif')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 0)
#apply Canny edge detection
canny_img = cv2.Canny(blurred, 150, 200)
#apply Distance Transform
invert_canny= 255- canny_img
dist_trans= cv2.distanceTransform(invert_canny, cv2.DIST_L2, 3)
#normalize to visualize dist-transformed img
cv2.normalize(dist_trans, dist_trans, 0.0, 1.0, cv2.NORM_MINMAX)
# apply dilation
kernel=np.ones((3,3), np.uint8)
dilate=cv2.dilate(dist_trans,kernel, iterations=1)