filterTest.sml

  Download

More scripts: Pipeline

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
clear();
##definitions##
string filtertype$;
string sourcetype$;
string targettype$;
string sourcefilepath$;
string sourcefilepath2$;
string sourcefilepath3$;
string sourceobjectpath$;
string sourceobjectpath2$;
string sourceobjectpath3$;
string sourceobjectpath4$;
string sourceobjectpath5$;
string correctfilepath$;
string correctobjectpath$;
class FILEPATH sourcefile = sourcefilepath$;
class FILEPATH sourcefile2 = sourcefilepath2$;
class FILEPATH sourcefile3 = sourcefilepath3$;
class RVC_OBJITEM sourceobjitem;
sourceobjitem.SetFilePath(sourcefilepath$);
sourceobjitem.SetObjectPath(sourceobjectpath$);
class RVC_OBJITEM sourceobjitem2;
sourceobjitem2.SetFilePath(sourcefilepath$);
sourceobjitem2.SetObjectPath(sourceobjectpath2$);
class RVC_OBJITEM sourceobjitem3;
sourceobjitem3.SetFilePath(sourcefilepath$);
sourceobjitem3.SetObjectPath(sourceobjectpath3$);
class RVC_OBJITEM sourceobjitem4;
sourceobjitem4.SetFilePath(sourcefilepath$);
sourceobjitem4.SetObjectPath(sourceobjectpath4$);
class RVC_OBJITEM sourceobjitem5;
sourceobjitem5.SetFilePath(sourcefilepath$);
sourceobjitem5.SetObjectPath(sourceobjectpath5$);
string outfilepath$ = CreateTempFileName();
string rvcfilepath$ = CreateTempFileName();
class FILEPATH outfile = outfilepath$;
class FILEPATH correctfile = correctfilepath$;
class RVC_OBJITEM outobjitem;
CreateProjectFile(rvcfilepath$, "Filter Tests");
outobjitem.SetFilePath(rvcfilepath$);
outobjitem.SetObjectPath(correctobjectpath$);
class RVC_DESCRIPTOR desc;
desc.SetName(correctobjectpath$);
desc.SetDescription("Filter Tests");
outobjitem.CreateNew(desc, "RASTER");
####
class RVC_RASTER RDest;
numeric err = 0;
proc ReportError(numeric linenum, numeric err) {
	print ("FAILED - line: ", linenum, " , error: ", err); 
	Exit();
	}
### SOURCE ###
class IMAGE_PIPELINE_SOURCE source;
class IMAGE_PIPELINE_SOURCE source2;
class IMAGE_PIPELINE_SOURCE source3;
class IMAGE_PIPELINE_SOURCE source4;
class IMAGE_PIPELINE_SOURCE source5;
switch(sourcetype$) {
	case "JPEG":
		class IMAGE_PIPELINE_SOURCE_JPEG source_jpeg(sourcefile);
		source = source_jpeg;
		class IMAGE_PIPELINE_SOURCE_JPEG source_jpeg2(sourcefile2);
		source2 = source_jpeg2;
		class IMAGE_PIPELINE_SOURCE_JPEG source_jpeg3(sourcefile3);
		source3 = source_jpeg3;
		break;
	case "PNG":
		class IMAGE_PIPELINE_SOURCE_PNG source_png(sourcefile);
		source = source_png;
		class IMAGE_PIPELINE_SOURCE_PNG source_png2(sourcefile2);
		source2 = source_png2;
		class IMAGE_PIPELINE_SOURCE_PNG source_png3(sourcefile3);
		source3 = source_png3;
		break;
	case "WBMP":
		class IMAGE_PIPELINE_SOURCE_WBMP source_wbmp(sourcefile);
		source = source_wbmp;
		class IMAGE_PIPELINE_SOURCE_WBMP source_wbmp2(sourcefile2);
		source2 = source_wbmp2;
		class IMAGE_PIPELINE_SOURCE_WBMP source_wbmp3(sourcefile3);
		source3 = source_wbmp3;
		break;
	case "RVC":
		class IMAGE_PIPELINE_SOURCE_RVC source_rvc(sourceobjitem);
		source = source_rvc;
		class IMAGE_PIPELINE_SOURCE_RVC source_rvc2(sourceobjitem2);
		source2 = source_rvc2;
		class IMAGE_PIPELINE_SOURCE_RVC source_rvc3(sourceobjitem3);
		source3 = source_rvc3;
		class IMAGE_PIPELINE_SOURCE_RVC source_rvc4(sourceobjitem4);
		source4 = source_rvc4;
		class IMAGE_PIPELINE_SOURCE_RVC source_rvc5(sourceobjitem5);
		source5 = source_rvc5;
		break;
	default:
		Exit();
	break;
	}
err = source.Initialize();
if (err < 0) ReportError(_context.CurrentLineNum, err);
###########
### FILTER ###
class IMAGE_PIPELINE_FILTER filter;
switch(filtertype$) {
	case "FILTER_CACHEIMAGE":
		{
		# define by xml control
		numeric MemoryMaxUsage;
		numeric TileRows;
		numeric TileColumns;
		#
		class IMAGE_PIPELINE_FILTER_CACHEIMAGE filter_cacheimage(source, MemoryMaxUsage, TileRows, TileColumns);
		filter = filter_cacheimage;
		}
	break;
	case "FILTER_COLORBALANCE":
		{
		# define by xml control
		numeric Contrast;
		numeric Intensity;
		numeric Saturation;
		#
		class CBPARMS cbparms;
		cbparms.con_val = Contrast;
		cbparms.int_val = Intensity;
		cbparms.sat_val = Saturation;
		class IMAGE_PIPELINE_FILTER_COLORBALANCE filter_colorbalance(source, cbparms);
		filter = filter_colorbalance;
		}
	break;
	case "FILTER_COMPOSITE":
		{
		# define by xml control
		string PixelType$; #invalid to determine automatically
		#
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		err = source3.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_STAGE_ARRAY stages(source, source2, source3);
		class IMAGE_PIPELINE_FILTER_COMPOSITE filter_composite(stages, PixelType$);
		filter = filter_composite;
		}
	break;
	case "FILTER_CROP":
		{
		# define by xml control
		numeric cropx1, cropx2, cropy1, cropy2;
		#
		class RECT croprect;
		croprect.Set(cropx1, cropy1, cropx2, cropy2);
		class IMAGE_PIPELINE_FILTER_CROP filter_crop(source, croprect);
		filter = filter_crop;
		}
	break;
	case "FILTER_DATATYPE":
		{
		# define by xml control
		string DataType;
		string Mode;
		numeric MinValue;
		numeric MaxValue;
		#
		class IMAGE_PIPELINE_FILTER_DATATYPE filter_datatype;
		if (MinValue == 0 && MaxValue == 0)
			filter_datatype = new IMAGE_PIPELINE_FILTER_DATATYPE(source, DataType, Mode);
		else
			filter_datatype = new IMAGE_PIPELINE_FILTER_DATATYPE(source, DataType, Mode, MinValue, MaxValue);
		filter = filter_datatype;
		}
	break;
	case "FILTER_DEINDEX":
		{
		class IMAGE_PIPELINE_FILTER_DEINDEX filter_deindex(source);
		filter = filter_deindex;
		}
	break;
	case "FILTER_EXTEND":
		{
		#define by xml control
		numeric NumColumnsAdd;
		numeric NumRowsAdd;
		#
		class IMAGE_PIPELINE_FILTER_EXTEND filter_extend(source, NumColumnsAdd, NumRowsAdd, source.GetTotalColumns() + NumColumnsAdd, source.GetTotalRows() + NumRowsAdd);
		filter = filter_extend;
		}
	break;
	case "FILTER_FOCALTOPOGRAPHIC":
		{
		# define by xml control
		numeric DoAspect;
		string AspectDataType$;
		numeric DoProfile;
		numeric DoPlan;
		string CurvatureDataType$;
		string CurvatureUnits$;
		numeric DoShading;
		string ShadingDataType$;
		string ShadingMethod$;
		numeric DoSlope;
		string SlopeDataType$;
		string SlopeUnits$;
		string SurfaceFittingMethod$;
		numeric DirectionOfSun;
		numeric ElevationAngleOfSun;
		numeric ElevationScale;
		numeric XCellSize;
		numeric YCellSize;
		#
		class IMAGE_PIPELINE_FILTER_FOCALTOPOGRAPHIC_SETTINGS toposettings;
		toposettings.SetAspectParms(DoAspect, AspectDataType$);
		toposettings.SetCurvatureParms(DoProfile, DoPlan, CurvatureDataType$, CurvatureUnits$);
		toposettings.SetShadingParms(DoShading, ShadingDataType$, ShadingMethod$);
		toposettings.SetSlopeParms(DoSlope, SlopeDataType$, SlopeUnits$);
		toposettings.SetSurfaceFittingMethod(SurfaceFittingMethod$);
		toposettings.SetDirectionOfSun(DirectionOfSun);
		toposettings.SetElevationAngleOfSun(ElevationAngleOfSun);
		toposettings.SetElevationScale(ElevationScale);
		toposettings.SetXCellSize(XCellSize);
		toposettings.SetYCellSIze(YCellSize);
		class IMAGE_PIPELINE_FILTER_FOCALTOPOGRAPHIC filter_focaltopographic(source, toposettings);
		filter = filter_focaltopographic;
		}
	break;
	case "FILTER_FUSION_BASICHBS":
		{
		# define by xml control
		numeric MaxHighRes;
		numeric MaxRGB;
		#
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_FILTER_FUSION_BASICHBS filter_fusion_basichbs(source, source2, MaxHighRes, MaxRGB);
		filter = filter_fusion_basichbs;
		}
	break;
	case "FILTER_FUSION_BASICHIS":
		{
		# define by xml control
		numeric MaxHighRes;
		numeric MaxRGB;
		#
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_FILTER_FUSION_BASICHIS filter_fusion_basichis(source, source2, MaxHighRes, MaxRGB);
		filter = filter_fusion_basichis;
		}
	break;
	case "FILTER_FUSION_BROVEY":
		{
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_FILTER_FUSION_BROVEY filter_fusion_brovey(source, source2);
		filter = filter_fusion_brovey;
		}
	break;
	case "FILTER_FUSION_MODHIS":
		{
		# define by xml control
		numeric MaxHighRes;
		numeric MaxRGB;
		numeric Proportion;
		numeric Boost;
		numeric MaxSaturation;
		numeric UseEffectiveColorIntensity;
		#
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_FILTER_FUSION_MODHIS filter_fusion_modhis(source, source2, MaxHighRes, MaxRGB);
		filter_fusion_modhis.SetIntensityProportion(Proportion);
		filter_fusion_modhis.SetSaturationBoost(Boost);
		filter_fusion_modhis.SetSaturationMax(MaxSaturation);
		filter_fusion_modhis.SetUseEffectiveColorIntensity(UseEffectiveColorIntensity);
		filter = filter_fusion_modhis;
		}
	break;
	case "FILTER_FUSION_TEXTUREPCA":
		{
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_FILTER_FUSION_TEXTUREPCA filter_fusion_texturepca(source, source2);
		filter = filter_fusion_texturepca;
		}
	break;
	case "FILTER_LINEAR":
		{
		#define by xml control
		numeric Coefficient;
		numeric Offset;
		#
		class IMAGE_PIPELINE_FILTER_LINEAR filter_linear(source);
		numeric i = 0;
		for i = 0 to source.GetNumSamples() {
			filter_linear.SetCoefficient(i, i, Coefficient);
			filter_linear.SetOffset(i, Offset);
			}
		filter = filter_linear;
		if (targettype$ == "JPEG" || targettype$ == "J2K" || targettype$ == "PNG") {
			err = filter_linear.Initialize();
			if (err < 0) ReportError(_context.CurrentLineNum, err);
			class IMAGE_PIPELINE_FILTER_DATATYPE filter_uint8(filter_linear, "UINT8", "Rescale", 0, 255);
			filter = filter_uint8;
			}
		}
	break;
	case "FILTER_LOOKUP":
		{
		class IMAGE_PIPELINE_SAMPLETABLE sampletable;
		class IMAGE_PIPELINE_SAMPLE sample("Gray", "UINT8");
		sampletable.Create(sample, 255);
		numeric i = 0;
		for i = 0 to 254
			sampletable.SetItem(i, 255-i);
		class IMAGE_PIPELINE_FILTER_LOOKUP filter_lookup(source);
		filter_lookup.SetSampleTable(0, sampletable, 0, 1);
		filter = filter_lookup;
		}
	break;
	case "FILTER_MASKVALIDITY":
		{
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_FILTER_MASKVALIDITY filter_maskvalidity(source, source2);
		filter = filter_maskvalidity;
		}
	break;
	case "FILTER_MORPHOLOGY_CLOSING":
		{
		# define by xml control
		numeric NumRows;
		numeric NumColumns;
		string Shape$;
		numeric OnValue;
		numeric OffValue;
		string Rotation$;
		#
		class IMAGE_PIPELINE_FILTER_MORPHOLOGY_CLOSING filter_morphology_closing(source);
		filter_morphology_closing.SetMatrix(NumRows, NumColumns, Shape$, OnValue, OffValue, Rotation$);
		filter = filter_morphology_closing;
		}
	break;
	case "FILTER_MORPHOLOGY_DILATION":
		{
		# define by xml control
		numeric NumRows;
		numeric NumColumns;
		string Shape$;
		numeric OnValue;
		numeric OffValue;
		string Rotation$;
		#
		class IMAGE_PIPELINE_FILTER_MORPHOLOGY_DILATION filter_morphology_dilation(source);
		filter_morphology_dilation.SetMatrix(NumRows, NumColumns, Shape$, OnValue, OffValue, Rotation$);
		filter = filter_morphology_dilation;
		}
	break;
	case "FILTER_MORPHOLOGY_EROSION":
		{
		# define by xml control
		numeric NumRows;
		numeric NumColumns;
		string Shape$;
		numeric OnValue;
		numeric OffValue;
		string Rotation$;
		#
		class IMAGE_PIPELINE_FILTER_MORPHOLOGY_EROSION filter_morphology_erosion(source);
		filter_morphology_erosion.SetMatrix(NumRows, NumColumns, Shape$, OnValue, OffValue, Rotation$);
		filter = filter_morphology_erosion;
		}
	break;
	case "FILTER_MORPHOLOGY_OPENING":
		{
		# define by xml control
		numeric NumRows;
		numeric NumColumns;
		string Shape$;
		numeric OnValue;
		numeric OffValue;
		string Rotation$;
		#
		class IMAGE_PIPELINE_FILTER_MORPHOLOGY_OPENING filter_morphology_opening(source);
		filter_morphology_opening.SetMatrix(NumRows, NumColumns, Shape$, OnValue, OffValue, Rotation$);
		filter = filter_morphology_opening;
		}
	break;
	case "FILTER_MOSAIC":
		{
		# define by xml control
		numeric TotalColumns;
		numeric TotalRows;
		string ResampleMethod$;
		string OverlapMethod$;
		string InputCRS$;
		string OutputCRS$;
		#
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		err = source3.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		err = source4.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		err = source5.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_STAGE_ARRAY stages(source2, source3, source4, source5);
		#by dimensions and trans map gen:
		#class IMAGE_PIPELINE_DIMENSIONS dimensions;
		#dimensions.SetTotalDimensions(TotalColumns, TotalRows);
		#class SR_COORDREFSYS inputcrs, outputcrs;
		#inputcrs.Assign(InputCRS$);
		#outputcrs.Assign(OutputCRS$);
		#class TRANS2D_MAPGEN TransMapGen;
		#TransMapGen.InputCoordRefSys = inputcrs;
		#TransMapGen.OutputCoordRefSys = outputcrs;
		#class IMAGE_PIPELINE_FILTER_MOSAIC filter_mosaic(stages, dimensions, TransMapGen, ResampleMethod$, OverlapMethod$);
		#use reference image to mosaic
		class IMAGE_PIPELINE_FILTER_MOSAIC filter_mosaic(stages, source, ResampleMethod$, OverlapMethod$);
		filter = filter_mosaic;
		}
	break;
	case "FILTER_MULTIPLY":
		{
		err = source2.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		err = source3.Initialize();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_STAGE_ARRAY stages(source, source2, source3);
		class IMAGE_PIPELINE_PIXEL pixel("Grayscale", "UINT8");
		class IMAGE_PIPELINE_FILTER_MULTIPLY filter_multiply(stages, pixel);
		filter = filter_multiply;
		}
	break;
	case "FILTER_OVERRIDETYPE":
		{
		# define by xml control
		string PixelType$;
		#
		class IMAGE_PIPELINE_FILTER_OVERRIDETYPE filter_overridetype(source, PixelType$);
		filter = filter_overridetype;
		}
	break;
	case "FILTER_PIXELTABLE":
		{
		class IMAGE_PIPELINE_PIXELTABLE table;
		class IMAGE_PIPELINE_PIXEL pixelprop("Grayscale", "UINT8");
		pixelprop.SetValueMaximum();
		table.Create(pixelprop, 255);
		table.SetAll(pixelprop);
		class IMAGE_PIPELINE_FILTER_PIXELTABLE filter_pixeltable(source, table);
		filter = filter_pixeltable;
		}
	break;
	case "FILTER_PIXELTYPE":
		{
		# define by xml control
		string TargetPixelType$;
		numeric ColorMaxValue;
		string TargetDataType$;
		#
		class IMAGE_PIPELINE_FILTER_PIXELTYPE filter_pixeltype(source, TargetPixelType$, ColorMaxValue, TargetDataType$);
		filter = filter_pixeltype;
		}
	break;
	case "FILTER_QUANTIZE":
		{
		class IMAGE_PIPELINE_SAMPLETABLE sampletable;
		class IMAGE_PIPELINE_SAMPLE sample("Gray", "UINT8");
		sampletable.Create(sample, 17);
		sampletable.SetItem(0, 15);
		sampletable.SetItem(1, 30);
		sampletable.SetItem(2, 45);
		sampletable.SetItem(3, 60);
		sampletable.SetItem(4, 75);
		sampletable.SetItem(5, 90);
		sampletable.SetItem(6, 105);
		sampletable.SetItem(7, 120);
		sampletable.SetItem(8, 135);
		sampletable.SetItem(9, 150);
		sampletable.SetItem(10, 165);
		sampletable.SetItem(11, 180);
		sampletable.SetItem(12, 195);
		sampletable.SetItem(13, 210);
		sampletable.SetItem(14, 225);
		sampletable.SetItem(15, 240);
		sampletable.SetItem(16, 255);
		class IMAGE_PIPELINE_FILTER_QUANTIZE filter_quantize(source);
		filter_quantize.SetSampleTable(0, sampletable);
		filter = filter_quantize;
		}
	break;
	case "FILTER_REPLACENULL":
		{
		# define by xml control
		numeric ValueReplace;
		#
		class IMAGE_PIPELINE_FILTER_REPLACENULL filter_replacenull(source, ValueReplace);
		filter = filter_replacenull;
		}
	break;
	case "FILTER_RESAMPLE":
		{
		# Get the Source raster and Target raster locations
		class RVC_RASTER SrcRastObj;
		err = SrcRastObj.Open(sourceobjitem);
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		# Get the extents of the Source raster in Map coordinates
		class RVC_GEOREFERENCE SrcGeorefObj;
		err = SrcRastObj.GetDefaultGeoref(SrcGeorefObj);
		if (err < 0) { print("Error:", err, "  On Line:", _context.CurrentLineNum);  Exit();  }
		err = SrcGeorefObj.OpenAttached();
		if (err < 0) { print("Error:", err, "  On Line:", _context.CurrentLineNum);  Exit();  }
		class TRANSMODEL TransModel;
		TransModel.SetType("None");
		class TRANS2D_MAPGEN TransSrcObjToMap;
		err = SrcGeorefObj.GetTransParm(TransSrcObjToMap, 0, TransModel);
		if (err < 0) { print("Error:", err, "  On Line:", _context.CurrentLineNum);  Exit();  }
		class RECT3D SrcObjExtents;
		SrcRastObj.GetExtents(SrcObjExtents);
		class POINT2D ptUL, ptUR, ptLL, ptLR;
		ptUL.x = 0;
		ptUL.y = SrcRastObj.GetNumLines();
		ptUR.x = SrcRastObj.GetNumColumns();
		ptUR.y = SrcRastObj.GetNumLines();
		ptLL.x = 0;
		ptLL.y = 0;
		ptLR.x = SrcRastObj.GetNumColumns();
		ptLR.y = 0;
		ptUL = TransSrcObjToMap.ConvertPoint2DFwd(ptUL);
		ptUR = TransSrcObjToMap.ConvertPoint2DFwd(ptUR);
		ptLL = TransSrcObjToMap.ConvertPoint2DFwd(ptLL);
		ptLR = TransSrcObjToMap.ConvertPoint2DFwd(ptLR);
		# Make the Target raster
		class RVC_RASTER TgtRastObj;
		# This function call will soon be replaced by future methods added to the RVC_RASTER class
		CreateRaster(TgtRastObj, outobjitem.GetFilePath(), outobjitem.GetDescriptor().GetFullName(), outobjitem.GetDescriptor().GetDescription(), SrcRastObj.GetNumLines(), SrcRastObj.GetNumColumns(), RastType(SrcRastObj)); 
		err = TgtRastObj.OpenAttached();
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		outobjitem = TgtRastObj.GetObjItem();
		# Specific projection for the target raster
		class SR_COORDREFSYS TgtCRS;
		TgtCRS.Create("1200", "2347", "25286"); # NAD83 UTM Zone 13N
		# Convert the Source map coordinates to extents in the new projection
		class TRANS2D_MAPGEN TransMapSrcToTgt;
		TransMapSrcToTgt.InputCoordRefSys = SrcGeorefObj.GetCoordRefSys();
		TransMapSrcToTgt.OutputCoordRefsys = TgtCRS;
		ptUL = TransMapSrcToTgt.ConvertPoint2DFwd(ptUL);
		ptUR = TransMapSrcToTgt.ConvertPoint2DFwd(ptUR);
		ptLL = TransMapSrcToTgt.ConvertPoint2DFwd(ptLL);
		ptLR = TransMapSrcToTgt.ConvertPoint2DFwd(ptLR);
		class RECT3D TgtMapExtents;
		TgtMapExtents.SetInvalid();
		TgtMapExtents.ExtendPoint(ptUL);
		TgtMapExtents.ExtendPoint(ptUR);
		TgtMapExtents.ExtendPoint(ptLL);
		TgtMapExtents.ExtendPoint(ptLR);
		# Create a control point georeference for the Target raster
		# This example uses the same number of lines and columns for the
		# Target raster as was in the source raster.
		class RVC_GEOREFERENCE TgtGeorefObj;
		TgtGeorefObj.SetCoordRefSys(TgtCRS);
		class CTRLPOINT CtrlPoint[4];
		CtrlPoint[1].source.x = 0;
		CtrlPoint[1].source.y = 0;
		CtrlPoint[1].dest.x = TgtMapExtents.x1;
		CtrlPoint[1].dest.y = TgtMapExtents.y2;
		CtrlPoint[2].source.x = SrcRastObj.GetNumColumns();
		CtrlPoint[2].source.y = 0;
		CtrlPoint[2].dest.x = TgtMapExtents.x2;
		CtrlPoint[2].dest.y = TgtMapExtents.y2;
		CtrlPoint[3].source.x = 0;
		CtrlPoint[3].source.y = SrcRastObj.GetNumLines();
		CtrlPoint[3].dest.x = TgtMapExtents.x1;
		CtrlPoint[3].dest.y = TgtMapExtents.y1;
		CtrlPoint[4].source.x = SrcRastObj.GetNumColumns();
		CtrlPoint[4].source.y = SrcRastObj.GetNumLines();
		CtrlPoint[4].dest.x = TgtMapExtents.x2;
		CtrlPoint[4].dest.y = TgtMapExtents.y1;
		err = TgtGeorefObj.SetPointList(CtrlPoint);
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		err = TgtGeorefObj.Make(TgtRastObj);
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class TRANS2D_MAPGEN TransTgtToSrc;
		err = TgtRastObj.ComputeObjectTranslation(SrcRastObj, TransTgtToSrc);
		if (err < 0) ReportError(_context.CurrentLineNum, err);
		class IMAGE_PIPELINE_DIMENSIONS Dimensions;
		Dimensions.SetTotalDimensions(SrcRastObj.GetNumColumns(), SrcRastObj.GetNumLines());
		class IMAGE_PIPELINE_FILTER_RESAMPLE filter_resample(source, Dimensions, TransTgtToSrc, "Nearest");
		filter = filter_resample;
		}
	break;
	case "FILTER_SCALEOFFSET":
		{
		#define by xml control
		numeric Scale, Offset;
		#
		class IMAGE_PIPELINE_FILTER_SCALEOFFSET filter_scaleoffset(source);
		numeric i;
		for i = 0 to source.GetNumSamples() - 1 {
			err = filter_scaleoffset.SetScaleOffset(i, Scale, Offset);
			if (err < 0) ReportError(_context.CurrentLineNum, err);
			}
		filter = filter_scaleoffset;
		}
	break;
	case "FILTER_SELECT":
		{
		# define by xml control
		numeric SampleNum;
		#
		array numeric SrcSamples[1];
		SrcSamples[1] = SampleNum;
		class IMAGE_PIPELINE_FILTER_SELECT filter_select(source, SrcSamples, 1);
		filter = filter_select;
		}
	break;
	case "FILTER_ZOOM":
		{
		#define by xml control
		string PrevStageUsage$;
		string ResampleMethod$;
		numeric ZoomScale;
		#
		class IMAGE_PIPELINE_FILTER_ZOOM filter_zoom(source, ZoomScale, PrevStageUsage$, ResampleMethod$);
		filter = filter_zoom;
		}
	break;
	default:
		Exit();
	break;
	}
err = filter.Initialize();
if (err < 0) ReportError(_context.CurrentLineNum, err);
###########
### TARGET ###
class IMAGE_PIPELINE_TARGET target;
switch(targettype$) {
	case "JPEG":
		outfile.SetExtension("JPG");
		outfilepath$ = outfile;
		class IMAGE_PIPELINE_TARGET_JPEG target_jpeg(filter, outfile);
		target = target_jpeg;
	break;
	case "J2K":
		outfile.SetExtension("jp2");
		outfilepath$ = outfile;
		class IMAGE_PIPELINE_TARGET_J2K_SETTINGS j2ksettings;
		class IMAGE_PIPELINE_TARGET_J2K target_j2k(filter, outfile, j2ksettings);
		target = target_j2k;
	break;
	case "PNG":
		outfile.SetExtension("png");
		outfilepath$ = outfile;
		class IMAGE_PIPELINE_TARGET_PNG target_png(filter, outfile);
		target = target_png;
	break;
	case "TIFF":
		outfile.SetExtension("TIF");
		outfilepath$ = outfile;
		class IMAGE_PIPELINE_TARGET_TIFF target_tiff(filter, outfile);
		target = target_tiff;
	break;
	case "RVC":
		class IMAGE_PIPELINE_TARGET_RVC target_rvc(filter, outobjitem);
		target = target_rvc;
	break;
	default:
		Exit();
	break;
	}
err = target.Initialize();
if (err < 0) ReportError(_context.CurrentLineNum, err);
err = target.Process();
if (err < 0) ReportError(_context.CurrentLineNum, err);
if (targettype$ == "RVC") {
	class RVC_OBJITEM targetobjitem;
	targetobjitem.SetFilePath(correctfilepath$);
	targetobjitem.SetObjectPath(correctobjectpath$);
	if (!targetobjitem.IsExisting()) {#no known good exists
		print("FAILED - No correct image exists for ", filtertype$);
		if (!correctfile.IsFile()) {
			CopyFile(rvcfilepath$, correctfilepath$);
			}
		CopyObject(rvcfilepath$, 1, correctfilepath$);
		}
	OpenRaster(RDest, rvcfilepath$, correctobjectpath$);
	}
else {
	if (!correctfile.IsFile()) { #no known good exists
		print("FAILED - No correct image exists for ", filtertype$);
		CopyFile(outfilepath$, correctfilepath$);
		}
	RDest.OpenByName(outfile, outfile.GetNameOnly());
	}
######
outfile.Delete();
print("Process Completed");
###