python - OpenCV Opening/Closing shifts the positions of the pixels -
i'm using morphology transformations on binary images opencv 2.4
i noticed using built-in functions of opencv, pixels' positions shifted right , down 1 (i.e. pixel located @ (i,j) located @ (i+1, j+1))
import cv2 import numpy np skimage.morphology import opening image = cv2.imread('input.png', 0) kernel = np.ones((16,16), np.uint8) opening_opencv = cv2.morphologyex(image, cv2.morph_open, kernel) opening_skimage = opening(image, kernel) cv2.imwrite('opening_opencv.png', opening_opencv) cv2.imwrite('opening_skimage.png', opening_skimage)
input :
output :
as didn't understand why, tied same operation using skimage, , doesn't make "gap" during morphological transformation.
ouput :
any idea issue ?
thanks !
it way commented, exact inverse :)
structuring elements size lead shifts, there no middle pixel. odd size, middle pixel , (n-1)/2 pixels @ each size.
other way of saying se odd sizes symmetric , size asymmetric.
Comments
Post a Comment