imgfft

Capsim Block Documentation

Short Description

This block inputs an image and computes its forward or inverse FFT. For a forward FFT a real matrix is expected and a complex image is produced. For an inverse FFT a complex image is expected ( possible result of a forward FFT). Complex images store real and imaginary parts as even and odd sample

Top
Input Connections
Port Type Name
0 image_t x
Top
Output Connections
Port Type Name
0 image_t y
Top
Parameters
Num Description Type Name Default Value
0 Operation: 0=Forward FFT, 1= Inverse FFT int fftType 0
1 Center: 0=None , 1= Yes int centerFlag 0
2 1=free input image, 0= don't int freeImageFlag 0
Top
States
Num Type Name Initial Value Description
0 float** mat_PP
1 float** matTrans_PP
2 int pwidth
3 int pheight
4 image_t img
5 dsp_floatMatrix_Pt fftMat_P
6 dsp_floatMatrix_t matrix
7 float* window_P
Top

Declarations


 

	int no_samples;
	int i,j,k;
	int	factor;
	float	temp;
	float	tempReal;
	float	tempImag;
	int fftexp;
        int fftl;
        int fftwidth;
	float	norm;
	int	pts;
	int	order;



Top

Initialization Code



 

window_P=NULL;




Top

Main Code



 

/*
 * collect the image
 */
for (no_samples = MIN_AVAIL(); no_samples > 0; --no_samples) {
	IT_IN(0);
	img=x(0);
	pheight=img.height;
	pwidth=img.width;

	if(fftType == FORWARD_FFT && pwidth != pheight) {
		fprintf(stderr,"2-D FFT of Square images only. Sorry!\n");
		return(1);
	}
	if(fftType == INVERSE_FFT && pwidth != 2*pheight) {
		fprintf(stderr,"2-D FFT of Square images only. Sorry!\n");
		return(1);
	}
	/*
	 * round points to next power of 2
	 */
	order = (int) (log((float)pwidth)/log(2.0)+0.5);
	pts = 1 << order;
	if (pts > pwidth ) {
        	pts = pts/2;
        	order -= 1;
	}

	window_P=(float*)calloc(pts,sizeof(float));
	if(window_P == NULL) {
		fprintf(stderr,"imgfft: could not allocate space\n");
		return(3);
	}
	for(i=0; iwidth;
	   img.height=fftMat_P->height;
    	   img.image_PP=fftMat_P->matrix_PP;
	   if(IT_OUT(0)) {
				KrnOverflow("imgfft",0);
				return(99);
	   }
	   y(0) = img;
	
			
}
return(0);




Top

Wrapup Code



 





Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2002  XCAD Corporation 

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.xcad.com
    XCAD Corporation
    Raleigh, North Carolina 
*/


Top

Description



 

/* imgfft.s */
/***********************************************************************
                             imgfft()
************************************************************************
This star inputs an image and computes its forward or inverse FFT.
For a forward FFT a real matrix is expected and a complex image is
produced.
For an inverse FFT a complex image is expected ( possible result of a 
forward FFT).
Complex images store real and imaginary parts as even and odd sample 
columns. Thus for complex images width =2*height.
Programmer:  	Sasan Ardalan	
Date: 		September 10, 1993
*/