/* -*- c-basic-offset: 3; mode: c++ -*-
 *
 * PANDORE (PANTHEON Project)
 *
 * GREYC IMAGE
 * 6 Boulevard Maréchal Juin
 * F-14050 Caen Cedex France
 *
 * This file is free software. You can use it, distribute it
 * and/or modify it. However, the entire risk to the quality
 * and performance of this program is with you.
 *
 * Please email any bugs, comments, and/or additions to this file to:
 * pandore@greyc.ensicaen.fr
 * http://www.greyc.ensicaen.fr/EquipeImage/Pandore/
 */

/**
 * @author Régis Clouard - 1997-02-22
 */

#include <pandore.h>
using namespace pandore;

/**
 * @file pzoom.cpp
 * Agrandissement ou reduction d'une image.
 * zoomx	: Facteur d'agrandissement en X.
 * zoomy	: Facteur d'agrandissement en Y.
 * zoomz	: Facteur d'agrandissement en Z.
 *
 * imd(i,j) = ims(i/zoomy,j/zoomx).
 */











Errc PZoom( const Img2duc &ims, Img2duc &imd, float zoomy, float zoomx ) {
  Point2d p;
  
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd[p] = ims[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }

  return SUCCESS;
}

Errc PZoom( const Img2dsl &ims, Img2dsl &imd, float zoomy, float zoomx ) {
  Point2d p;
  
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd[p] = ims[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }

  return SUCCESS;
}

Errc PZoom( const Img2dsf &ims, Img2dsf &imd, float zoomy, float zoomx ) {
  Point2d p;
  
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd[p] = ims[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }

  return SUCCESS;
}

Errc PZoom( const Img3duc &ims, Img3duc &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd[p]=ims[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}
Errc PZoom( const Img3dsl &ims, Img3dsl &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd[p]=ims[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}
Errc PZoom( const Img3dsf &ims, Img3dsf &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd[p]=ims[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}

Errc PZoom( const Imc2duc &ims, Imc2duc &imd, float zoomy, float zoomx ) {
  Point2d p;
  
  imd.ColorSpace(ims.ColorSpace());
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd.X[p] = ims.X[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
     imd.Y[p] = ims.Y[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
     imd.Z[p] = ims.Z[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }

  return SUCCESS;
}

Errc PZoom( const Imc2dsl &ims, Imc2dsl &imd, float zoomy, float zoomx ) {
  Point2d p;
  
  imd.ColorSpace(ims.ColorSpace());
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd.X[p] = ims.X[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
     imd.Y[p] = ims.Y[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
     imd.Z[p] = ims.Z[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }

  return SUCCESS;
}

Errc PZoom( const Imc2dsf &ims, Imc2dsf &imd, float zoomy, float zoomx ) {
  Point2d p;
  
  imd.ColorSpace(ims.ColorSpace());
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd.X[p] = ims.X[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
     imd.Y[p] = ims.Y[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
     imd.Z[p] = ims.Z[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }

  return SUCCESS;
}

Errc PZoom( const Imc3duc &ims, Imc3duc &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
  imd.ColorSpace(ims.ColorSpace());
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd.X[p]=ims.X[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
     imd.Y[p]=ims.Y[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
     imd.Z[p]=ims.Z[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}
Errc PZoom( const Imc3dsl &ims, Imc3dsl &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
  imd.ColorSpace(ims.ColorSpace());
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd.X[p]=ims.X[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
     imd.Y[p]=ims.Y[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
     imd.Z[p]=ims.Z[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}
Errc PZoom( const Imc3dsf &ims, Imc3dsf &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
  imd.ColorSpace(ims.ColorSpace());
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     imd.X[p]=ims.X[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
     imd.Y[p]=ims.Y[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
     imd.Z[p]=ims.Z[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}

Errc PZoom( const Imx2duc &ims, Imx2duc &imd, float zoomy, float zoomx ) {
  Point2d p;
  
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     for (int b=0;b<ims.Bands();b++)
	imd[b][p] = ims[b][(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }
  
  return SUCCESS;
}

Errc PZoom( const Imx2dsl &ims, Imx2dsl &imd, float zoomy, float zoomx ) {
  Point2d p;
  
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     for (int b=0;b<ims.Bands();b++)
	imd[b][p] = ims[b][(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }
  
  return SUCCESS;
}

Errc PZoom( const Imx2dsf &ims, Imx2dsf &imd, float zoomy, float zoomx ) {
  Point2d p;
  
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     for (int b=0;b<ims.Bands();b++)
	imd[b][p] = ims[b][(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }
  
  return SUCCESS;
}

Errc PZoom( const Imx3duc &ims, Imx3duc &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     for (int b=0;b<ims.Bands();b++)
	imd[b][p]=ims[b][int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}
Errc PZoom( const Imx3dsl &ims, Imx3dsl &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     for (int b=0;b<ims.Bands();b++)
	imd[b][p]=ims[b][int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}
Errc PZoom( const Imx3dsf &ims, Imx3dsf &imd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
    
   for (p.z=0;p.z<imd.Depth();p.z++)
   for (p.y=0;p.y<imd.Height();p.y++)
   for (p.x=0;p.x<imd.Width();p.x++)
  {
     for (int b=0;b<ims.Bands();b++)
	imd[b][p]=ims[b][int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  
  return SUCCESS;
}

Errc PZoom( const Reg2d &rgs, Reg2d &rgd, float zoomy, float zoomx ) {
  Point2d p;

  rgd.Labels(rgs.Labels());
   for (p.y=0;p.y<rgd.Height();p.y++)
   for (p.x=0;p.x<rgd.Width();p.x++)
  {
     rgd[p] = rgs[(int)(p.y/zoomy)][(int)(p.x/zoomx)];
  }
  return SUCCESS;
}

Errc PZoom( const Reg3d &rgs, Reg3d &rgd, float zoomz, float zoomy, float zoomx ) {
  Point3d p;
  
  rgd.Labels(rgs.Labels());
   for (p.z=0;p.z<rgd.Depth();p.z++)
   for (p.y=0;p.y<rgd.Height();p.y++)
   for (p.x=0;p.x<rgd.Width();p.x++)
  {
     rgd[p]=rgs[int(p.z/zoomz)][int(p.y/zoomy)][int(p.x/zoomx)];
  }
  return SUCCESS;
}


Errc PZoom( const Graph2d &grs, Graph2d &grd,  float zoomy, float zoomx ) {
   GEdge *l;

   for (int i=0; i< grs.Size(); i++){
      if (grs[i] != NULL){
	 grd.Add(i,grs[i]->Item(),(int)(grs[i]->seed.y*zoomy),(int)(grs[i]->seed.x*zoomx));
	 grd[i]->value=grs[i]->value;
	 for (l=grs[i]->Neighbours(); l!=NULL; l=l->Next()){
	    if (i>l->Node())
	       grd.Link(i,l->Node(),l->weight);
	 }
      }
   }
   
   return SUCCESS;
}

Errc PZoom( const Graph3d &grs, Graph3d &grd, float zoomz, float zoomy, float zoomx ) {
   GEdge *l;
   
   for (int i=0; i< grs.Size(); i++){
      if (grs[i] != NULL){
	 grd.Add(i,grs[i]->Item(),(int)(grs[i]->seed.z*zoomz),(int)(grs[i]->seed.y*zoomy),(int)(grs[i]->seed.x*zoomx));
	 grd[i]->value=grs[i]->value;
	 for (l=grs[i]->Neighbours(); l!=NULL; l=l->Next()){
	    if (i>l->Node())
	       grd.Link(i,l->Node(),l->weight);
	 }
      }
   }

   return SUCCESS;
}


#ifdef MAIN
#define	USAGE	"usage: %s zoomx zoomy zoomz [im_in|-] [im_out|-]"
#define	PARC	3
#define	FINC	1
#define	FOUTC	1
#define	MASK	0

int main( int argc, char *argv[] ) {
   Errc result;              // The result code of the execution.
   Pobject* mask;            // The region map.
   Pobject* objin[FINC+1];   // The input objects;
   Pobject* objs[FINC+1];    // The source objects masked.
   Pobject* objout[FOUTC+1]; // The output object.
   Pobject* objd[FOUTC+1];   // The result object of the execution.
   char* parv[PARC+1];       // The input parameters.

   ReadArgs(argc,argv,PARC,FINC,FOUTC,&mask,objin,objs,objout,objd,parv,USAGE,MASK);
   if (objs[0]->Type() == Po_Img2duc) {
      Img2duc* const ims=(Img2duc*)objs[0];
      objd[0]=new Img2duc(Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Img2duc* const imd=(Img2duc*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Img2dsl) {
      Img2dsl* const ims=(Img2dsl*)objs[0];
      objd[0]=new Img2dsl(Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Img2dsl* const imd=(Img2dsl*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Img2dsf) {
      Img2dsf* const ims=(Img2dsf*)objs[0];
      objd[0]=new Img2dsf(Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Img2dsf* const imd=(Img2dsf*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Img3duc) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Img3duc* const ims=(Img3duc*)objs[0];
      objd[0]=new Img3duc(Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Img3duc* const imd=(Img3duc*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Img3dsl) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Img3dsl* const ims=(Img3dsl*)objs[0];
      objd[0]=new Img3dsl(Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Img3dsl* const imd=(Img3dsl*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Img3dsf) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Img3dsf* const ims=(Img3dsf*)objs[0];
      objd[0]=new Img3dsf(Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Img3dsf* const imd=(Img3dsf*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imc2duc) {
      Imc2duc* const ims=(Imc2duc*)objs[0];
      objd[0]=new Imc2duc(Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imc2duc* const imd=(Imc2duc*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imc2dsl) {
      Imc2dsl* const ims=(Imc2dsl*)objs[0];
      objd[0]=new Imc2dsl(Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imc2dsl* const imd=(Imc2dsl*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imc2dsf) {
      Imc2dsf* const ims=(Imc2dsf*)objs[0];
      objd[0]=new Imc2dsf(Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imc2dsf* const imd=(Imc2dsf*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imc3duc) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Imc3duc* const ims=(Imc3duc*)objs[0];
      objd[0]=new Imc3duc(Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imc3duc* const imd=(Imc3duc*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imc3dsl) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Imc3dsl* const ims=(Imc3dsl*)objs[0];
      objd[0]=new Imc3dsl(Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imc3dsl* const imd=(Imc3dsl*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imc3dsf) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Imc3dsf* const ims=(Imc3dsf*)objs[0];
      objd[0]=new Imc3dsf(Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imc3dsf* const imd=(Imc3dsf*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imx2duc) {
      Imx2duc* const ims=(Imx2duc*)objs[0];
      objd[0]=new Imx2duc(ims->Bands(),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imx2duc* const imd=(Imx2duc*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imx2dsl) {
      Imx2dsl* const ims=(Imx2dsl*)objs[0];
      objd[0]=new Imx2dsl(ims->Bands(),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imx2dsl* const imd=(Imx2dsl*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imx2dsf) {
      Imx2dsf* const ims=(Imx2dsf*)objs[0];
      objd[0]=new Imx2dsf(ims->Bands(),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imx2dsf* const imd=(Imx2dsf*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*ims,*imd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imx3duc) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Imx3duc* const ims=(Imx3duc*)objs[0];
      objd[0]=new Imx3duc(ims->Bands(),Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imx3duc* const imd=(Imx3duc*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imx3dsl) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Imx3dsl* const ims=(Imx3dsl*)objs[0];
      objd[0]=new Imx3dsl(ims->Bands(),Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imx3dsl* const imd=(Imx3dsl*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Imx3dsf) {
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) return FAILURE;
      Imx3dsf* const ims=(Imx3dsf*)objs[0];
      objd[0]=new Imx3dsf(ims->Bands(),Long(ims->Depth()*atof(parv[2])),Long(ims->Height()*atof(parv[1])),Long(ims->Width()*atof(parv[0])));
      Imx3dsf* const imd=(Imx3dsf*)objd[0];
      result=PZoom(*ims,*imd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Reg2d) {
      Reg2d* const rgs=(Reg2d*)objs[0];
      objd[0]=new Reg2d(Long(rgs->Height()*atof(parv[1])),Long(rgs->Width()*atof(parv[0])));
      Reg2d* const rgd=(Reg2d*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*rgs,*rgd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Reg3d) {
      Reg3d* const rgs=(Reg3d*)objs[0];
      objd[0]=new Reg3d(Long(rgs->Depth()*atof(parv[2])),Long(rgs->Height()*atof(parv[1])),Long(rgs->Width()*atof(parv[0])));
      Reg3d* const rgd=(Reg3d*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0)) result=FAILURE;
      else result=PZoom(*rgs,*rgd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Graph2d) {
      Graph2d* const grs=(Graph2d*)objs[0];
      objd[0]=new Graph2d(grs->Size(),Long(grs->Height()*atoi(parv[1])),Long(grs->Width()*atoi(parv[0])));
      Graph2d* const grd=(Graph2d*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0)) result=FAILURE;
      else result=PZoom(*grs,*grd,(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

   if (objs[0]->Type() == Po_Graph3d) {
      Graph3d* const grs=(Graph3d*)objs[0];
      objd[0]=new Graph3d(grs->Size(),Long(atoi(parv[2])*grs->Depth()),Long(atoi(parv[1])*grs->Height()),Long(atoi(parv[0])*grs->Width()));
      Graph3d* const grd=(Graph3d*)objd[0];
      if ( (atof(parv[0])<=0) || (atof(parv[1])<=0) || (atof(parv[2])<=0))
	 result= FAILURE;
      else
	 result=PZoom(*grs,*grd,(float)atof(parv[2]),(float)atof(parv[1]),(float)atof(parv[0]));
      goto end;
   }

  {
     PrintErrorFormat(objin,FINC);
     result = FAILURE;
  }	

end:
  if (result)
	WriteArgs(argc,argv,PARC,FINC,FOUTC,&mask,objin,objs,objout,objd,MASK);
  Exit(result);
  return 0;
}
#endif
