I am having a slight issue with my code and honestly cannot understand what I am doing wrong. I am currently trying to using a high pass filter in the frequency domain to form the following image.(adsbygoogle = window.adsbygoogle || []).push({});

So my approach so far after numerous of attempts which I wont list as I believe I am on the correct path, is to use a low pass filter matrix and then subtract from the original image, the issue is I cannot subtract due to the matrix of the low pass filter image being different from the original.

The image being produced from this code is shown belowCode (Text):%reading in the image

A=imread('coins.png');

%applying fouire transform shift to zero postion and fouire transform for

%2D

D = fftshift(fft2(A));

%defing the filter, Low pass filter

h = (1/9).*[1,1,1;1,1,1;1,1,1];

%apllying filter to the frequency domain

B1=filter2(h1,D);

B1 = uint8(round(B1));

G=ifft2(B1);

imshow(log(abs(G)))

But when I run the code to subtract the I get the error code:

As you can see I have tried to make the images the same size yet it still is not working and I am at a slight loss to why.Code (Text):%reading in the image

A=imread('coins.png');

%applying fouire transform shift to zero postion and fouire transform for

%2D

D = fftshift(fft2(A));

%defing the filter, Low pass filter

h = (1/9).*[1,1,1;1,1,1;1,1,1];

%apllying filter to the freqencey domian

B1=filter2(h1,D);

B1 = uint8(round(B1));

G=ifft2(B1);

E=imshow(log(abs(G)))

J = imresize(A,[246 300])

imsubtract(J,E)

Error code

Error using imsubtract (line 52)

X and Y must have the same size and class, or Y must be a scalar double.

Error in signla (line 84)

imsubtract(J,E)

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# High pass filtering FFT2 matlab

Tags:

Have something to add?

**Physics Forums | Science Articles, Homework Help, Discussion**