2 Replies - 31555 Views - Last Post: 02 March 2010 - 05:21 AM Rate Topic: -----

#1 khanjan  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 16-January 10

matlab code for gaussian filter in digital image processing

Posted 16 January 2010 - 07:50 AM

[size=6][code]
f=imread('C:\Users\images\Image0671.jpg');
PQ=paddedsize(size(f));
F=fft2(f,PQ(1),PQ(2));
for i= 1:PQ(1)
for j=i:PQ(2)
H(i,j)=exp(-(i^2+j^2));
end
end
H=fftshift(H);
G=H.*F;
g=real(ifft2(g));
g=g(1:size(f,1),1:size(f,2));
figure,imshow(f)
figure,imshow(H)
code[/]
Is This A Good Question/Topic? 1
  • +

Replies To: matlab code for gaussian filter in digital image processing

#2 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: matlab code for gaussian filter in digital image processing

Posted 16 January 2010 - 11:05 PM

Do you need help?

Are you submitting a snippet of code?

What?

:code:

size 6 font is unnecessary, by the way
Was This Post Helpful? 0
  • +
  • -

#3 Predictor  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 90
  • Joined: 20-September 07

Re: matlab code for gaussian filter in digital image processing

Posted 02 March 2010 - 05:21 AM

It seems that this part could be vectorized:

for i= 1:PQ(1)
for j=i:PQ(2)
H(i,j)=exp(-(i^2+j^2));
end
end



I suggest something like the following:

[I J] = meshgrid(1:PQ(1),1:PQ(2);
H = exp(-(I.^2 + J.^2));



I may have gotten the dimensions backwards, but I think that is pretty close to right.


-Will Dwinnell
Data Mining in MATLAB
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1