# matlab code for gaussian filter in digital image processing

Page 1 of 1

## 2 Replies - 42331 Views - Last Post: 02 March 2010 - 05:21 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=150253&amp;s=6c89cce8a8638cc3f06fdb3bd74aa876&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 khanjan

Reputation: 1
• 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=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

• D.I.C Lover

Reputation: 486
• 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?

size 6 font is unnecessary, by the way

### #3 Predictor

Reputation: 12
• Posts: 91
• 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