public IFunctionRasterDataset fastGLCMFunction(object inRaster, int clms, int rws, bool horizontal, glcmMetric glcmType) { FunctionRasters.NeighborhoodHelper.glcmHelperBase glcmB = new FunctionRasters.NeighborhoodHelper.glcmHelperBase(); glcmB.RasterUtility = this; glcmB.InRaster = createIdentityRaster(inRaster, rstPixelType.PT_FLOAT); glcmB.Columns = clms; glcmB.Rows = rws; glcmB.Horizontal = horizontal; glcmB.GlCM_Metric = glcmType; glcmB.WindowType = windowType.RECTANGLE; glcmB.calcGLCM(); return glcmB.OutRaster; }
/// <summary> /// Performs GLMC Analysis. All bands within the input raster will be transformed /// </summary> /// <param name="inRaster">raster to perform GLCM</param> /// <param name="radius">number of Columns that define the radius of the analysis window</param> /// <param name="horizontal">whether the direction of the GLCM is horizontal</param> /// <param name="glcmType">the type of GLCM to calculate</param> /// <returns>a transformed raster</returns> public IFunctionRasterDataset calcGLCMFunction(object inRaster, int radius, bool horizontal, glcmMetric glcmType) { 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 (glcmType) { case glcmMetric.CONTRAST: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperContrast(); break; case glcmMetric.DIS: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperDissimilarity(); break; case glcmMetric.HOMOG: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperHomogeneity(); break; case glcmMetric.ASM: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperASM(); break; case glcmMetric.ENERGY: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperEnergy(); break; case glcmMetric.MAXPROB: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperMaxProb(); break; case glcmMetric.MINPROB: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperMinProb(); break; case glcmMetric.RANGE: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperRange(); break; case glcmMetric.ENTROPY: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperEntropy(); break; case glcmMetric.MEAN: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperMean(); break; case glcmMetric.VAR: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperVariance(); break; case glcmMetric.CORR: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperCorrelation(); break; case glcmMetric.COV: rsFunc = new FunctionRasters.NeighborhoodHelper.glcmHelperCovariance(); break; default: break; } FunctionRasters.glcmFunctionArguments args = new FunctionRasters.glcmFunctionArguments(this); args.Radius = radius; args.InRaster = iR1; args.Horizontal = horizontal; args.GLCMMETRICS = glcmType; frDset.Init(rsFunc, args); return frDset; }