hello! i m learning about Dog filtering from examples. and i succeed to print some filters, but not all.
problem is print Dog_x filter, Dog_y filter.
sceens are so small and not showing.
i think this is mask problem.
could you help to check my code?
thank you !!!
here is my code.
import cv2
import numpy as np
import os, sys
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from my_filtering_true import my_filtering
def get_DoG_filter(fsize, sigma=1):
y, x = np.mgrid[-(fsize//2):(fsize//2)+1, -(fsize//2):(fsize//2)+1]
DoG_x = (-x/sigma**2) * np.exp(-(x**2+y**2)/(2*sigma**2))
DoG_y = (-y/sigma**2) * np.exp(-(x**2+y**2)/(2*sigma**2))
return DoG_x, DoG_y
def main():
src = cv2.imread('Lena.png', cv2.IMREAD_GRAYSCALE)
DoG_x, DoG_y = get_DoG_filter(fsize=3, sigma=1)
x, y = get_DoG_filter(fsize=256, sigma=10)
x = ((DoG_x-np.min(DoG_x))/np.max(DoG_x- np.min(DoG_x))*255).astype(np.uint8)
y = ((DoG_y-np.min(DoG_y))/np.max(DoG_y- np.min(DoG_y))*255).astype(np.uint8)
dst_x = my_filtering(src, DoG_x)
dst_y = my_filtering(src, DoG_y)
dst = np.sqrt((dst_x)**2 + (dst_y)**2)
cv2.imshow('DoG_x filter ', x)
cv2.imshow('DoG_y filter ', y)
cv2.imshow('dst_x ', dst_x/255)
cv2.imshow('dst_y ', dst_y/255)
cv2.imshow('dst ', dst/255)
cv2.waitKey()
cv2.destroyAllWindows()
if __name__ == '__main__':
main()