Difference between revisions of "File:Fafo2test1.png"
(Importing image file) |
|||
Line 1: | Line 1: | ||
+ | Modullus of the [[Fourier-2 transform]] of the bi–dimiensional real array [[File:Fafo2test0.png|128px]]. |
||
− | Importing image file |
||
+ | |||
+ | The density of rectangles represents $|A(x,y)|$ of $|B(x,y)|$ in the $x,y$ plane. |
||
+ | |||
+ | The discrete implementation of the Fourier–2 transform approximates the integral transform $B$ of the function $A$ in the following form: |
||
+ | : $\displaystyle B(p,q)=\frac{1}{2\pi} \int \int \mathrm d x \mathrm d y \exp(-ipx-iqy) A(x,y)$ |
||
+ | |||
+ | The spots, that determine the structure of the "face" shown, are barely seen around the central spot; |
||
+ | their intensity is only few percents of the intensity at the central spot. |
||
+ | |||
+ | ==[[C++]] generator== |
||
+ | |||
+ | // Files [[ado.cin]] and [[fafo.cin]] should be loaded in the working directory in order to compile the code below: |
||
+ | |||
+ | #include<math.h> |
||
+ | #include<stdio.h> |
||
+ | #include <stdlib.h> |
||
+ | #include <complex> |
||
+ | using namespace std; |
||
+ | #define z_type complex<double> |
||
+ | #define DB double |
||
+ | #define DO(x,y) for(x=0;x<y;x++) |
||
+ | |||
+ | #include "fafo.cin" |
||
+ | #include "ado.cin" |
||
+ | |||
+ | main(){ int m,M=64, n,N=64; DB x,y, dx,dy, u,v, s,t; |
||
+ | z_type c,z; |
||
+ | FILE *o; |
||
+ | o=fopen("fafo2test1.eps","w"); ado(o, 10*M+2, 10*N+2); |
||
+ | fprintf(o,"1 1 translate\n"); |
||
+ | fprintf(o,"10 10 scale\n"); |
||
+ | |||
+ | z_type *A; A=(z_type *)malloc((size_t)((M*N)*sizeof(z_type))); |
||
+ | z_type *b; b=(z_type *)malloc((size_t)((M)*sizeof(z_type))); |
||
+ | |||
+ | // Assuming M >= N |
||
+ | dx=sqrt(2.*M_PI/M); |
||
+ | dy=sqrt(2.*M_PI/N); |
||
+ | DO(m,M){ x=dx*(m-M/2.); |
||
+ | DO(n,N){ y=dy*(n-N/2.); if(.3*x*x+.2*y*y >2.1) A[n*M+m]=0.; else A[n*M+m]=1.; |
||
+ | if(fabs(x)<.8 && fabs(y+1.7)<.3 ) A[n*M+m]-=1.; |
||
+ | if( (fabs(x-1.)<.3 || fabs(x+1.)<.3 ) && fabs(y-.8)<.2 ) A[n*M+m]-=1.; |
||
+ | }} |
||
+ | DO(m,M){ DO(n,N) b[n]=A[n*M+m]; fafo(b,N,1); DO(n,N) A[n*M+m]=b[n]; } |
||
+ | DO(n,N){ DO(m,M) b[m]=A[n*M+m]; fafo(b,M,1); DO(m,M) A[n*M+m]=b[m]; } |
||
+ | fprintf(o,"gsave\n"); |
||
+ | fprintf(o,"%2d %2d scale\n",M,N); |
||
+ | fprintf(o,"%2d %2d 4 [%2d 0 0 %2d 0 %2d]\n<", M,N,M,-N,N); |
||
+ | s=0; DO(m,M) DO(n,N){ t=abs(A[n*M+m]); if(t>s) s=t; } |
||
+ | s=15./s; |
||
+ | for(n=N-1;n>=0;n--) { fprintf(o,"\n"); |
||
+ | DO(m,M){ fprintf(o,"%1x",int(s*abs(A[n*M+m])+.6) ); |
||
+ | }} |
||
+ | fprintf(o,"\n>\n"); |
||
+ | fprintf(o,"image\n"); |
||
+ | free(A); |
||
+ | fprintf(o,"grestore\n"); |
||
+ | #define M(x,y) fprintf(o,"%6.3f %6.3f M\n",0.+x,0.+y); |
||
+ | #define L(x,y) fprintf(o,"%6.3f %6.3f L\n",0.+x,0.+y); |
||
+ | M(M/2.+.5,-1); L(M/2+.5,N+1); |
||
+ | M(-1,N/2.+.5); L(M+1,N/2.+.5); |
||
+ | fprintf(o,"1 0 0 RGB .1 W S\n"); |
||
+ | fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o); |
||
+ | system("epstopdf fafo2test1.eps"); |
||
+ | system( "convert fafo2test1.eps fafo2test1.png "); |
||
+ | system( "open fafo2test1.png"); |
||
+ | } |
||
+ | // Copyleft 2011 by Dmitrii Kouznetsov |
||
+ | |||
+ | ==[[EPS]] version== |
||
+ | |||
+ | %!PS-Adobe-2.0 EPSF-2.0 |
||
+ | |||
+ | %%BoundingBox: 0 0 642 642 |
||
+ | /M {moveto} bind def |
||
+ | /L {lineto} bind def |
||
+ | /S {stroke} bind def |
||
+ | /s {show newpath} bind def |
||
+ | /C {closepath} bind def |
||
+ | /F {fill} bind def |
||
+ | /o {.1 0 360 arc C S} bind def |
||
+ | /times-Roman findfont 20 scalefont setfont |
||
+ | /W {setlinewidth} bind def |
||
+ | /RGB {setrgbcolor} bind def |
||
+ | 1 1 translate |
||
+ | 10 10 scale |
||
+ | gsave |
||
+ | 64 64 scale |
||
+ | 64 64 4 [64 0 0 -64 0 64] |
||
+ | < |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000111000000000000000111000000000000000000000 |
||
+ | 0000000000000000000000011000000000000000110000000000000000000000 |
||
+ | 0000000000000000000000000000111111111000000000000000000000000000 |
||
+ | 0000000000000000000000000001111111111100000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 1100000000000000000000011111000000000111110000000000000000000001 |
||
+ | 0000000000000011000000111111000000000111111000000110000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000111000000000000000000000000000000 |
||
+ | 1000000000000000000000011100011111110001110000000000000000000000 |
||
+ | 1000000001000111000001111000111111111000111100000111000100000000 |
||
+ | 0000000011001111000000000001111111111100000000000111100110000000 |
||
+ | 0000000010001110000000000000000000000000000000000011100010000000 |
||
+ | 0000000000011100000000000010011111110010000000000001110000000000 |
||
+ | 0000000000111000000000011111111111111111110000000000111000000000 |
||
+ | 0000000001110000000100111111111111111111111001000000011100000000 |
||
+ | 0000000000000000011000111110111111111011111000110000000000000000 |
||
+ | 0000000000000000110001110011122222221110011100011000000000000000 |
||
+ | 1100000000011100100011101111111111111111101110001001110000000001 |
||
+ | 1000000000011100100111011211001111100112110111001001110000000000 |
||
+ | 0000000000011101001110112110122222221011211011100101110000000000 |
||
+ | 0000000100011001001111122112222111222211221111100100110001000000 |
||
+ | 0000000110011011001101121122211232112221121101100110110011000000 |
||
+ | 0000000100000000001101111122125787521221111101100000000001000000 |
||
+ | 0000000000010000001001110222159cdc951222011100100000010000000000 |
||
+ | 000000000001000000100111022126aefea62122011100100000010000000000 |
||
+ | 0000000000010000001001110222159cdc951222011100100000010000000000 |
||
+ | 0000000100000000001101111122125787521221111101100000000001000000 |
||
+ | 0000000110011011001101121122211232112221121101100110110011000000 |
||
+ | 0000000100011001001111122112222111222211221111100100110001000000 |
||
+ | 0000000000011101001110112110122222221011211011100101110000000000 |
||
+ | 1000000000011100100111011211001111100112110111001001110000000000 |
||
+ | 1100000000011100100011101111111111111111101110001001110000000001 |
||
+ | 0000000000000000110001110011122222221110011100011000000000000000 |
||
+ | 0000000000000000011000111110111111111011111000110000000000000000 |
||
+ | 0000000001110000000100111111111111111111111001000000011100000000 |
||
+ | 0000000000111000000000011111111111111111110000000000111000000000 |
||
+ | 0000000000011100000000000010011111110010000000000001110000000000 |
||
+ | 0000000010001110000000000000000000000000000000000011100010000000 |
||
+ | 0000000011001111000000000001111111111100000000000111100110000000 |
||
+ | 1000000001000111000001111000111111111000111100000111000100000000 |
||
+ | 1000000000000000000000011100011111110001110000000000000000000000 |
||
+ | 0000000000000000000000000000000111000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000011000000111111000000000111111000000110000000000000 |
||
+ | 1100000000000000000000011111000000000111110000000000000000000001 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000001111111111100000000000000000000000000 |
||
+ | 0000000000000000000000000000111111111000000000000000000000000000 |
||
+ | 0000000000000000000000011000000000000000110000000000000000000000 |
||
+ | 0000000000000000000000111000000000000000111000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
||
+ | 0000000000000000000000000001100000001100000000000000000000000000 |
||
+ | > |
||
+ | image |
||
+ | grestore |
||
+ | 32.500 -1.000 M |
||
+ | 32.500 65.000 L |
||
+ | -1.000 32.500 M |
||
+ | 65.000 32.500 L |
||
+ | 1 0 0 RGB .1 W S |
||
+ | showpage |
||
+ | %%Trailer |
||
+ | |||
+ | ==Keywords== |
||
+ | [[Foutier-transform]], |
||
+ | [[Image]] |
||
+ | [[gsave]] |
||
+ | [[grestore]] |
||
+ | |||
+ | ==References== |
||
+ | |||
+ | [[Category:Fourier transform]] |
||
+ | [[Category:EPS]] |
||
+ | [[Category:Roster images]] |
Latest revision as of 09:39, 21 June 2013
Modullus of the Fourier-2 transform of the bi–dimiensional real array .
The density of rectangles represents $|A(x,y)|$ of $|B(x,y)|$ in the $x,y$ plane.
The discrete implementation of the Fourier–2 transform approximates the integral transform $B$ of the function $A$ in the following form:
- $\displaystyle B(p,q)=\frac{1}{2\pi} \int \int \mathrm d x \mathrm d y \exp(-ipx-iqy) A(x,y)$
The spots, that determine the structure of the "face" shown, are barely seen around the central spot;
their intensity is only few percents of the intensity at the central spot.
C++ generator
// Files ado.cin and fafo.cin should be loaded in the working directory in order to compile the code below:
#include<math.h> #include<stdio.h> #include <stdlib.h> #include <complex> using namespace std; #define z_type complex<double> #define DB double #define DO(x,y) for(x=0;x<y;x++)
#include "fafo.cin" #include "ado.cin"
main(){ int m,M=64, n,N=64; DB x,y, dx,dy, u,v, s,t; z_type c,z; FILE *o; o=fopen("fafo2test1.eps","w"); ado(o, 10*M+2, 10*N+2); fprintf(o,"1 1 translate\n"); fprintf(o,"10 10 scale\n");
z_type *A; A=(z_type *)malloc((size_t)((M*N)*sizeof(z_type))); z_type *b; b=(z_type *)malloc((size_t)((M)*sizeof(z_type)));
// Assuming M >= N dx=sqrt(2.*M_PI/M); dy=sqrt(2.*M_PI/N); DO(m,M){ x=dx*(m-M/2.); DO(n,N){ y=dy*(n-N/2.); if(.3*x*x+.2*y*y >2.1) A[n*M+m]=0.; else A[n*M+m]=1.; if(fabs(x)<.8 && fabs(y+1.7)<.3 ) A[n*M+m]-=1.; if( (fabs(x-1.)<.3 || fabs(x+1.)<.3 ) && fabs(y-.8)<.2 ) A[n*M+m]-=1.; }} DO(m,M){ DO(n,N) b[n]=A[n*M+m]; fafo(b,N,1); DO(n,N) A[n*M+m]=b[n]; } DO(n,N){ DO(m,M) b[m]=A[n*M+m]; fafo(b,M,1); DO(m,M) A[n*M+m]=b[m]; } fprintf(o,"gsave\n"); fprintf(o,"%2d %2d scale\n",M,N); fprintf(o,"%2d %2d 4 [%2d 0 0 %2d 0 %2d]\n<", M,N,M,-N,N); s=0; DO(m,M) DO(n,N){ t=abs(A[n*M+m]); if(t>s) s=t; } s=15./s; for(n=N-1;n>=0;n--) { fprintf(o,"\n"); DO(m,M){ fprintf(o,"%1x",int(s*abs(A[n*M+m])+.6) ); }} fprintf(o,"\n>\n"); fprintf(o,"image\n"); free(A); fprintf(o,"grestore\n"); #define M(x,y) fprintf(o,"%6.3f %6.3f M\n",0.+x,0.+y); #define L(x,y) fprintf(o,"%6.3f %6.3f L\n",0.+x,0.+y); M(M/2.+.5,-1); L(M/2+.5,N+1); M(-1,N/2.+.5); L(M+1,N/2.+.5); fprintf(o,"1 0 0 RGB .1 W S\n"); fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o); system("epstopdf fafo2test1.eps"); system( "convert fafo2test1.eps fafo2test1.png "); system( "open fafo2test1.png"); }
// Copyleft 2011 by Dmitrii Kouznetsov
EPS version
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 642 642
/M {moveto} bind def /L {lineto} bind def /S {stroke} bind def /s {show newpath} bind def /C {closepath} bind def /F {fill} bind def /o {.1 0 360 arc C S} bind def /times-Roman findfont 20 scalefont setfont /W {setlinewidth} bind def /RGB {setrgbcolor} bind def 1 1 translate 10 10 scale gsave 64 64 scale 64 64 4 [64 0 0 -64 0 64] < 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000111000000000000000111000000000000000000000 0000000000000000000000011000000000000000110000000000000000000000 0000000000000000000000000000111111111000000000000000000000000000 0000000000000000000000000001111111111100000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 1100000000000000000000011111000000000111110000000000000000000001 0000000000000011000000111111000000000111111000000110000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000111000000000000000000000000000000 1000000000000000000000011100011111110001110000000000000000000000 1000000001000111000001111000111111111000111100000111000100000000 0000000011001111000000000001111111111100000000000111100110000000 0000000010001110000000000000000000000000000000000011100010000000 0000000000011100000000000010011111110010000000000001110000000000 0000000000111000000000011111111111111111110000000000111000000000 0000000001110000000100111111111111111111111001000000011100000000 0000000000000000011000111110111111111011111000110000000000000000 0000000000000000110001110011122222221110011100011000000000000000 1100000000011100100011101111111111111111101110001001110000000001 1000000000011100100111011211001111100112110111001001110000000000 0000000000011101001110112110122222221011211011100101110000000000 0000000100011001001111122112222111222211221111100100110001000000 0000000110011011001101121122211232112221121101100110110011000000 0000000100000000001101111122125787521221111101100000000001000000 0000000000010000001001110222159cdc951222011100100000010000000000 000000000001000000100111022126aefea62122011100100000010000000000 0000000000010000001001110222159cdc951222011100100000010000000000 0000000100000000001101111122125787521221111101100000000001000000 0000000110011011001101121122211232112221121101100110110011000000 0000000100011001001111122112222111222211221111100100110001000000 0000000000011101001110112110122222221011211011100101110000000000 1000000000011100100111011211001111100112110111001001110000000000 1100000000011100100011101111111111111111101110001001110000000001 0000000000000000110001110011122222221110011100011000000000000000 0000000000000000011000111110111111111011111000110000000000000000 0000000001110000000100111111111111111111111001000000011100000000 0000000000111000000000011111111111111111110000000000111000000000 0000000000011100000000000010011111110010000000000001110000000000 0000000010001110000000000000000000000000000000000011100010000000 0000000011001111000000000001111111111100000000000111100110000000 1000000001000111000001111000111111111000111100000111000100000000 1000000000000000000000011100011111110001110000000000000000000000 0000000000000000000000000000000111000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000011000000111111000000000111111000000110000000000000 1100000000000000000000011111000000000111110000000000000000000001 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000001111111111100000000000000000000000000 0000000000000000000000000000111111111000000000000000000000000000 0000000000000000000000011000000000000000110000000000000000000000 0000000000000000000000111000000000000000111000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000001100000001100000000000000000000000000 > image grestore 32.500 -1.000 M 32.500 65.000 L -1.000 32.500 M 65.000 32.500 L 1 0 0 RGB .1 W S showpage
%%Trailer
Keywords
Foutier-transform, Image gsave grestore
References
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 17:50, 20 June 2013 | 642 × 642 (8 KB) | Maintenance script (talk | contribs) | Importing image file |
You cannot overwrite this file.
File usage
The following 3 pages use this file: