FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-27-2003, 06:08 PM
CDB
Guest
 
Posts: n/a
Default how does matlab zero pad on fft

hello,

i am trying to compare my versus matlab's implementaion of a
convolution in the frequency domain.

i have a mask that is not the same size of the image (in fact its much
smaller). but i fft2 the mask with the dimensions of the image and
then convolve with the fft2 of the image.

my question i, what method is used for zero padding the mask to be the
same size of the image?

can someone tell me for example of what the resulting mask would look
like if my original filter was:

-1 0 1
-1 0 1
-1 0 1

and my image size was 128x128? i.e. calling fft2(mask,128,128)

basically i am trying to figure out if the mask stays in the center,
is shoved to the bottom left, or top left etc.

also trying to understand if the mask gets chopped up and centered
around the middle zero and shoved to the bottom left corner.

thank you, happy holidays.
Reply With Quote
  #2 (permalink)  
Old 11-27-2003, 11:42 PM
Rune Allnor
Guest
 
Posts: n/a
Default Re: how does matlab zero pad on fft

[email protected] (CDB) wrote in message news:<[email protected] com>...
> hello,
>
> i am trying to compare my versus matlab's implementaion of a
> convolution in the frequency domain.
>
> i have a mask that is not the same size of the image (in fact its much
> smaller). but i fft2 the mask with the dimensions of the image and
> then convolve with the fft2 of the image.
>
> my question i, what method is used for zero padding the mask to be the
> same size of the image?
>
> can someone tell me for example of what the resulting mask would look
> like if my original filter was:
>
> -1 0 1
> -1 0 1
> -1 0 1
>
> and my image size was 128x128? i.e. calling fft2(mask,128,128)
>
> basically i am trying to figure out if the mask stays in the center,
> is shoved to the bottom left, or top left etc.
>
> also trying to understand if the mask gets chopped up and centered
> around the middle zero and shoved to the bottom left corner.
>
> thank you, happy holidays.


If you do like this,

S=real(ifft(fft(ones(3,3),6,6))) % Note no semicolon!

you will see directly where matlab inserts the zeros.

Rune
Reply With Quote
  #3 (permalink)  
Old 11-28-2003, 12:25 AM
Fred Marshall
Guest
 
Posts: n/a
Default Re: how does matlab zero pad on fft


"Rune Allnor" <[email protected]> wrote in message
news:[email protected] om...
> [email protected] (CDB) wrote in message

news:<[email protected] com>...
> > hello,
> >
> > i am trying to compare my versus matlab's implementaion of a
> > convolution in the frequency domain.
> >
> > i have a mask that is not the same size of the image (in fact its much
> > smaller). but i fft2 the mask with the dimensions of the image and
> > then convolve with the fft2 of the image.
> >
> > my question i, what method is used for zero padding the mask to be the
> > same size of the image?
> >
> > can someone tell me for example of what the resulting mask would look
> > like if my original filter was:
> >
> > -1 0 1
> > -1 0 1
> > -1 0 1
> >
> > and my image size was 128x128? i.e. calling fft2(mask,128,128)
> >
> > basically i am trying to figure out if the mask stays in the center,
> > is shoved to the bottom left, or top left etc.
> >
> > also trying to understand if the mask gets chopped up and centered
> > around the middle zero and shoved to the bottom left corner.
> >
> > thank you, happy holidays.

>
> If you do like this,
>
> S=real(ifft(fft(ones(3,3),6,6))) % Note no semicolon!
>
> you will see directly where matlab inserts the zeros.


I didn't think it would insert zeros at all! I thought the size of the
transform was as specified and that "fft" really means "dft" unless the
dimension is 2^n.

Fred


Reply With Quote
  #4 (permalink)  
Old 11-28-2003, 09:54 AM
Rune Allnor
Guest
 
Posts: n/a
Default Re: how does matlab zero pad on fft

"Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message news:<[email protected]>...
> "Rune Allnor" <[email protected]> wrote in message
> news:[email protected] om...
> > [email protected] (CDB) wrote in message

> news:<[email protected] com>...
> > > hello,
> > >
> > > i am trying to compare my versus matlab's implementaion of a
> > > convolution in the frequency domain.
> > >
> > > i have a mask that is not the same size of the image (in fact its much
> > > smaller). but i fft2 the mask with the dimensions of the image and
> > > then convolve with the fft2 of the image.
> > >
> > > my question i, what method is used for zero padding the mask to be the
> > > same size of the image?
> > >
> > > can someone tell me for example of what the resulting mask would look
> > > like if my original filter was:
> > >
> > > -1 0 1
> > > -1 0 1
> > > -1 0 1
> > >
> > > and my image size was 128x128? i.e. calling fft2(mask,128,128)
> > >
> > > basically i am trying to figure out if the mask stays in the center,
> > > is shoved to the bottom left, or top left etc.
> > >
> > > also trying to understand if the mask gets chopped up and centered
> > > around the middle zero and shoved to the bottom left corner.
> > >
> > > thank you, happy holidays.

> >
> > If you do like this,
> >
> > S=real(ifft(fft(ones(3,3),6,6))) % Note no semicolon!
> >
> > you will see directly where matlab inserts the zeros.

>
> I didn't think it would insert zeros at all! I thought the size of the
> transform was as specified and that "fft" really means "dft" unless the
> dimension is 2^n.
>
> Fred


The matlab fft (which, BTW, should be fft2 in the 2D example above) does
insert zeros if you ask it to. In the example above I made a 3x3 matrix
with unit elements, and ask matlab to zero pad the data to a 6x6 matrix
before computing the DFT.

Rune
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matlab, RS-232, Ethernet satyam FPGA 8 03-13-2008 08:30 PM
Matlab (.m) to VHDL Vitaliy VHDL 3 01-02-2007 08:14 AM
Matlab (.m) to VHDL Vitaliy FPGA 3 01-02-2007 08:14 AM
Matlab and VHDL [email protected] VHDL 1 12-02-2006 10:49 AM
How to convert Matlab to HDL? Davy FPGA 3 06-14-2005 05:50 AM


All times are GMT +1. The time now is 02:18 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved