00001
00011 #include "utils.h"
00012 #include "inricache.h"
00013 #include <inrimage/image.h>
00014 #include <stdlib.h>
00015
00020 static char Ucmd[]=
00021 "[img] [dest] [-xp x_pas] [-yp y_pas] [-zp z_pas] [-x X] [-y Y] [-z Z] [-x0 X0] [-y0 Y0] [-z0 Z0] [-cache taille_cache] [-time]";
00022
00026 static char Udetail[]=
00027 "genere dest le sous-echantillonnage de img en coupant X0,Y0,Z0 ,par pas de x_pas,y_pas, ou bien de dimensions X,Y et Z.\nSi on donne un pas et une dimension, on prend en compte en priorite la dimension. Si aucun argument n'est donne, on prend un pas de 1.";
00028
00029 int main(int argc,char ** argv)
00030 {
00031 int x_pas,y_pas,z_pas;
00032 int x,y,z,x0,y0,z0;
00033 int time_flag,taille_cache,i;
00034 struct nf_fmt gfmt_in,gfmt_out;
00035 inricache *s2D,*d2D;
00036 char img2D[80]="",dest2D[80]="";
00037
00038 inr_init(argc,argv,"1.0",Ucmd,Udetail);
00039
00040 infileopt(img2D);
00041 outfileopt(dest2D);
00042
00043
00044 if (!igetopt1("-xp","%d",&x_pas))
00045 x_pas=1;
00046 if (!igetopt1("-yp","%d",&y_pas))
00047 y_pas=1;
00048 if (!igetopt1("-zp","%d",&z_pas))
00049 z_pas=1;
00050 if (!igetopt1("-x","%d",&x))
00051 x=0;
00052 if (!igetopt1("-y","%d",&y))
00053 y=0;
00054 if (!igetopt1("-z","%d",&z))
00055 z=0;
00056 if (!igetopt1("-x0","%d",&x0))
00057 x0=0;
00058 if (!igetopt1("-y0","%d",&y0))
00059 y0=0;
00060 if (!igetopt1("-z0","%d",&z0))
00061 z0=0;
00062 if (!igetopt1("-cache","%d",&taille_cache))
00063 taille_cache=1;
00064 time_flag=igetopt0("-time");
00065
00066
00067 if(tstopts())
00068 iusage_(Ucmd,Udetail);
00069
00070 s2D=cree_inricache(img2D,"e","",&gfmt_in,taille_cache);
00071
00072 for (i=0;i<9;i++)
00073 gfmt_out.lfmt[i]=gfmt_in.lfmt[i];
00074 for (i=0;i<3;i++)
00075 gfmt_out.offsets[i]=gfmt_in.offsets[i];
00076 gfmt_out.maille=gfmt_in.maille;
00077 gfmt_out.bias=gfmt_in.bias;
00078 gfmt_out.scale=gfmt_in.scale;
00079
00080 if (x==0)
00081 gfmt_out.lfmt[I_NDIMX]=(gfmt_out.lfmt[I_NDIMX]-x0)/x_pas;
00082 else
00083 gfmt_out.lfmt[I_NDIMX]=x;
00084 if (y==0)
00085 gfmt_out.lfmt[I_NDIMY]=(gfmt_out.lfmt[I_NDIMY]-y0)/y_pas;
00086 else
00087 gfmt_out.lfmt[I_NDIMY]=y;
00088 if (z==0)
00089 gfmt_out.lfmt[I_NDIMZ]=(gfmt_out.lfmt[I_NDIMZ]-z0)/z_pas;
00090 else
00091 gfmt_out.lfmt[I_NDIMZ]=z;
00092 gfmt_out.lfmt[I_DIMX]=gfmt_out.lfmt[I_NDIMX];
00093 gfmt_out.lfmt[I_DIMY]=gfmt_out.lfmt[I_NDIMZ]*gfmt_out.lfmt[I_NDIMY];
00094
00095 d2D=cree_inricache(dest2D,"c","a",&gfmt_out,taille_cache);
00096
00097 resize_inricache(s2D,d2D,x0,y0,z0,time_flag);
00098
00099 libere_inricache(s2D);
00100 libere_inricache(d2D);
00101
00102 return EXIT_SUCCESS;
00103 }