/// <summary>
 /// Will perform a focal raster operation on an input raster all bands
 /// </summary>
 /// <param name="inRaster">either IRaster, IRasterDataset, or a valid path pointing to a raster</param>
 /// <param name="radius">number of cells that make up the radius of a circle</param>
 /// <param name="statType">the type of opporation</param>
 /// <returns>a IRaster that can be used for further analysis</returns>
 public IFunctionRasterDataset calcFocalStatisticsFunction(object inRaster, int radius, focalType statType)
 {
     IFunctionRasterDataset iR1 = createIdentityRaster(inRaster);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = null;
     List<int[]> outLst = new List<int[]>();
     int[,] crl = null;
     double[] cArr = null;
     double sumCircle = 0;
     switch (statType)
     {
         case focalType.MIN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMin();
             break;
         case focalType.SUM:
             crl = createFocalWindowCircle(radius, out outLst);
             cArr = (from int i in crl select System.Convert.ToDouble(i)).ToArray();
             return convolutionRasterFunction(iR1,crl.GetUpperBound(0)+1,crl.GetUpperBound(1)+1,cArr);
         case focalType.MEAN:
             crl = createFocalWindowCircle(radius, out outLst);
             sumCircle = (from int i in crl select System.Convert.ToDouble(i)).Sum();
             cArr = (from int i in crl select System.Convert.ToDouble(i)).ToArray();
             IFunctionRasterDataset conRsMean = convolutionRasterFunction(iR1, crl.GetUpperBound(0) + 1, crl.GetUpperBound(1) + 1, cArr);
             return calcArithmaticFunction(conRsMean, sumCircle, esriRasterArithmeticOperation.esriRasterDivide);
         case focalType.MODE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMode();
             break;
         case focalType.MEDIAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMedian();
             break;
         case focalType.VARIANCE:
             crl = createFocalWindowCircle(radius, out outLst);
             cArr = (from int i in crl select System.Convert.ToDouble(i)).ToArray();
             double sumCr = cArr.Sum();
             IFunctionRasterDataset rs2 = calcMathRasterFunction(iR1, transType.SQUARED);
             IFunctionRasterDataset sumRs2 = convolutionRasterFunction(rs2, crl.GetUpperBound(0) + 1, crl.GetUpperBound(1) + 1, cArr);
             IFunctionRasterDataset sumRs2M = calcArithmaticFunction(sumRs2, sumCr, esriRasterArithmeticOperation.esriRasterDivide);
             IFunctionRasterDataset sumRs = convolutionRasterFunction(iR1, crl.GetUpperBound(0) + 1, crl.GetUpperBound(1) + 1, cArr);
             IFunctionRasterDataset sumRsSquared = calcMathRasterFunction(sumRs, transType.SQUARED);
             IFunctionRasterDataset difRs = calcArithmaticFunction(sumRsSquared, sumRs2, esriRasterArithmeticOperation.esriRasterMinus);
             return calcArithmaticFunction(difRs, sumCr, esriRasterArithmeticOperation.esriRasterDivide);
         case focalType.STD:
             IRaster var = createRaster(calcFocalStatisticsFunction(iR1, radius, focalType.VARIANCE));
             return calcMathRasterFunction(var, transType.SQRT);
         case focalType.UNIQUE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperUnique();
             break;
         case focalType.ENTROPY:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperEntropy();
             break;
         case focalType.ASM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperProbability();
             break;
         default:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMax();
             break;
     }
     FunctionRasters.FocalFunctionArguments args = new FunctionRasters.FocalFunctionArguments(this);
     args.Radius = radius;
     args.InRaster = iR1;
     args.Operation = statType;
     frDset.Init(rsFunc, args);
     return frDset;
 }
 /// <summary>
 /// Will perform a focal raster operation on an input raster all bands
 /// </summary>
 /// <param name="inRaster">either IRaster, IRasterDataset, or a valid path pointing to a raster</param>
 /// <param name="clm">number of columns (cells)</param>
 /// <param name="rws">number of rows</param>
 /// <param name="statType">the type of operation</param>
 /// <returns>a IRaster that can be used for further analysis</returns>
 public IFunctionRasterDataset calcFocalStatisticsFunction(object inRaster, int clm, int rws, focalType statType)
 {
     IFunctionRasterDataset iR1 = createIdentityRaster(inRaster,rstPixelType.PT_FLOAT);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = null;
     switch (statType)
     {
         case focalType.MIN:
         case focalType.MAX:
         case focalType.MEAN:
         case focalType.STD:
             return calcFocalStatisticsRectangle(inRaster, clm, rws, statType);
         case focalType.SUM:
             IFunctionRasterDataset mRs = calcFocalStatisticsFunction(inRaster, clm, rws, focalType.MEAN);
             return calcArithmaticFunction(mRs, clm * rws, esriRasterArithmeticOperation.esriRasterMultiply);
             //rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperSum();
             //break;
         case focalType.MODE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMode();
             break;
         case focalType.MEDIAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMedian();
             break;
         case focalType.VARIANCE:
             IFunctionRasterDataset rs = calcFocalStatisticsFunction(inRaster, clm, rws,focalType.STD);
             return calcArithmaticFunction(rs,2,esriRasterArithmeticOperation.esriRasterPower);
         case focalType.UNIQUE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperUnique();
             break;
         case focalType.ENTROPY:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperEntropy();
             break;
         case focalType.ASM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperProbability();
             break;
         default:
             break;
     }
     FunctionRasters.FocalFunctionArguments args = new FunctionRasters.FocalFunctionArguments(this);
     args.Rows = rws;
     args.Columns = clm;
     //args.WindowType = windowType.RECTANGLE;
     args.InRaster = iR1;
     args.Operation = statType;
     frDset.Init(rsFunc, args);
     return frDset;
 }