- #1

Taylor_1989

- 402

- 14

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.

So my approach so far after numerous of attempts which I won't 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 below

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.

So my approach so far after numerous of attempts which I won't 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.

Code:

```
%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)))
```

The image being produced from this code is shown below

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

Code:

```
%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)
```

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.