public void Bind(object pArgument)
 {
     if (pArgument is glcmFunctionArguments)
     {
         glcmFunctionArguments args = (glcmFunctionArguments)pArgument;
         inrs = args.InRaster;
         orig = args.OriginalRaster;
         inWindow = args.WindowType;
         iter = args.GenericIterator;
         clms = args.Columns;
         rws = args.Rows;
         radius = args.Radius;
         glcmMetrics = args.GLCMMETRICS;
         horizontal = args.Horizontal;
         myFunctionHelper.Bind(inrs);
         myFunctionHelperOrig.Bind(orig);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype = myRasterInfo.PixelType;
         myValidFlag = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: glcmFunctonArguments");
     }
 }
Exemplo n.º 2
0
 public void Bind(object pArgument)
 {
     if (pArgument is glcmFunctionArguments)
     {
         glcmFunctionArguments args = (glcmFunctionArguments)pArgument;
         inrs        = args.InRaster;
         orig        = args.OriginalRaster;
         inWindow    = args.WindowType;
         iter        = args.GenericIterator;
         clms        = args.Columns;
         rws         = args.Rows;
         radius      = args.Radius;
         glcmMetrics = args.GLCMMETRICS;
         horizontal  = args.Horizontal;
         myFunctionHelper.Bind(inrs);
         myFunctionHelperOrig.Bind(orig);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype  = myRasterInfo.PixelType;
         myValidFlag  = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: glcmFunctonArguments");
     }
 }
Exemplo n.º 3
0
        private void createRaster()
        {
            string rstNm    = cmbRaster.Text;
            string rstOut   = mtbOutName.Text.Trim();
            string windType = cmbWindowType.Text;
            string windDir  = cmbDirections.Text;
            string glcmType = cmbGlcmTypes.Text;
            int    clms     = System.Convert.ToInt32(nudColumns.Value);
            int    rows     = System.Convert.ToInt32(nudRows.Value);
            List <rasterUtil.glcmMetric> glcmArr = new List <rasterUtil.glcmMetric>();

            if (rstNm == "" || rstNm == null || rstOut == "" || rstOut == null)
            {
                MessageBox.Show("You must have both a raster and output name specified to use this tool!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (windType == null || windType == "" || windDir == "" || windDir == null)
            {
                MessageBox.Show("Window Type and Direction are not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (glcmType == null || glcmType == "" || glcmType == "" || glcmType == null)
            {
                MessageBox.Show("Glcm Type is not specified!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            bool horz = true;

            rasterUtil.windowType wt = (rasterUtil.windowType)Enum.Parse(typeof(rasterUtil.windowType), windType);
            rasterUtil.glcmMetric gm = (rasterUtil.glcmMetric)Enum.Parse(typeof(rasterUtil.glcmMetric), glcmType);
            if (windDir.ToUpper() != "HORIZONTAL")
            {
                horz = false;
            }
            bool radius = false;

            if (wt != rasterUtil.windowType.RECTANGLE)
            {
                radius = true;
            }

            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog((perm == false));
            System.DateTime t1 = System.DateTime.Now;
            rp.addMessage("Start date and time = " + t1.Month.ToString() + "\\" + t1.Day.ToString() + "\\" + t1.Year.ToString() + " " + t1.Hour.ToString() + ":" + t1.Minute.ToString() + ":" + t1.Second.ToString());
            rp.addMessage("Creating the following " + windDir + " GLCM surfaces for the specified Raster:");
            rp.stepPGBar(15);
            if (perm)
            {
                rp.Show();
            }
            rp.Refresh();
            rp.TopMost = true;
            foreach (rasterUtil.glcmMetric g in glcmArr)
            {
                rp.addMessage("\t" + g.ToString());
            }
            rp.Refresh();
            IRaster inRs = rstDic[rstNm];

            try
            {
                if (radius)
                {
                    rst = rstUtil.createRaster(rstUtil.fastGLCMFunction(inRs, clms, horz, gm));
                }
                else
                {
                    rst = rstUtil.createRaster(rstUtil.fastGLCMFunction(inRs, clms, rows, horz, gm));
                }
                if (mp != null && perm)
                {
                    IRasterLayer rsLyr = new RasterLayerClass();
                    //rstUtil.calcStatsAndHist(rst);
                    rsLyr.CreateFromRaster(rst);
                    rsLyr.Name    = rstOut;
                    rsLyr.Visible = false;
                    mp.AddLayer((ILayer)rsLyr);
                }
                System.DateTime t2 = System.DateTime.Now;
                rp.addMessage("End date and time = " + t2.Month.ToString() + "\\" + t2.Day.ToString() + "\\" + t2.Year.ToString() + " " + t2.Hour.ToString() + ":" + t2.Minute.ToString() + ":" + t2.Second.ToString());
                rp.stepPGBar(100);
                rp.Refresh();
                oNm = rstOut;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                rp.enableClose();
                this.Close();
            }
            return;
        }