High pass filters

Can anyone help me understand how the high_pass_x_y function is helping in smoothing out the image.

function:

def high_pass_x_y(image):
x_var = image[:, : , 1:, :] - image[:,:,:-1,:]
y_var = image[:, 1:,:,:] - image[:, : -1 , : , : ]
return x_var, y_var

Hi @ABHILASHA1, welcome to the community!

The high_pass_x_y function isn’t really used to help smooth out the image. It’s a helper function used in displaying the variation to help you visualize why we want to smooth out the image.

high_pass_x_y is just looking at the difference between each pixel and the one next to it to see how much they vary from each other. Using the range “1:” will give all the pixels from 1 to the end, and using the range “:-1” will give all the pixels from 0 to the pixel just before the end. So subtracting will give a first value that’s the difference between the image value at position 1 & position 0, the second value is the difference between image position 2 and 1, etc.

1 Like