public static void test(String directory) { ColorSegmentationWorker cs = new ColorSegmentationWorker(); //cs.Apply(@"C:\Users\yaoyichi\Desktop\", @"C:\Users\yaoyichi\Desktop\", "WMSImage_ms.png"); // AForge.Imaging.Filters.OtsuThreshold otsu = new AForge.Imaging.Filters.OtsuThreshold(); AForge.Imaging.Filters.BradleyLocalThresholding bradley = new AForge.Imaging.Filters.BradleyLocalThresholding(); Image<Gray, Byte> img = new Image<Gray, Byte>(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64.png"); Bitmap dstimg =bradley.Apply(img.Bitmap); dstimg.Save(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64-2.png"); // Image<Gray, Byte> img = new Image<Gray, Byte>(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64.png"); img = img.ThresholdAdaptive(new Gray(255), Emgu.CV.CvEnum.ADAPTIVE_THRESHOLD_TYPE.CV_ADAPTIVE_THRESH_GAUSSIAN_C,Emgu.CV.CvEnum.THRESH.CV_THRESH_BINARY,15,new Gray(0)); img.Save(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64-1.png"); }
public static void test(String directory) { ColorSegmentationWorker cs = new ColorSegmentationWorker(); //cs.Apply(@"C:\Users\yaoyichi\Desktop\", @"C:\Users\yaoyichi\Desktop\", "WMSImage_ms.png"); // AForge.Imaging.Filters.OtsuThreshold otsu = new AForge.Imaging.Filters.OtsuThreshold(); AForge.Imaging.Filters.BradleyLocalThresholding bradley = new AForge.Imaging.Filters.BradleyLocalThresholding(); Image <Gray, Byte> img = new Image <Gray, Byte>(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64.png"); Bitmap dstimg = bradley.Apply(img.Bitmap); dstimg.Save(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64-2.png"); // Image<Gray, Byte> img = new Image<Gray, Byte>(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64.png"); img = img.ThresholdAdaptive(new Gray(255), Emgu.CV.CvEnum.ADAPTIVE_THRESHOLD_TYPE.CV_ADAPTIVE_THRESH_GAUSSIAN_C, Emgu.CV.CvEnum.THRESH.CV_THRESH_BINARY, 15, new Gray(0)); img.Save(@"C:\Users\yaoyichi\Desktop\Images-22-10\576800_mc1024_k64-1.png"); }
protected override void OnClick() { string straboPath = Environment.GetEnvironmentVariable(ArcStrabo2Extension.EnvironmentVariableSTRABO_HOME, EnvironmentVariableTarget.User); string tessPath = Environment.GetEnvironmentVariable(ArcStrabo2Extension.EnvironmentVariableTESS_DATA, EnvironmentVariableTarget.User); if (ArcStrabo2Extension.PathSet == false) { if (String.IsNullOrEmpty(straboPath) == true) { MessageBox.Show(ArcStrabo2Extension.ErrorMsgNoStraboHome); return; } if (String.IsNullOrEmpty(tessPath) == true) { MessageBox.Show(ArcStrabo2Extension.ErrorMsgNoTess_Data); return; } bool Initialize_straboPath_Correct = ArcStrabo2Extension.initialize_straboPath_directories(straboPath); if (Initialize_straboPath_Correct == false) { MessageBox.Show(ArcStrabo2Extension.ErrorMsgNoStraboHomeWritePermission); return; } ArcStrabo2Extension.PathSet = true; } // // TODO: Sample code showing how to access button host // ArcMap.Application.CurrentTool = null; ComboBoxLayerSelector layerNameCombo = ComboBoxLayerSelector.GetLayerNameComboBox(); RasterLayer rasterlayer = new RasterLayer(); rasterlayer = ((RasterLayer)layerNameCombo.GetSelectedLayer()); //raster.Raster //RasterLayer raster2 = new RasterLayer(); //raster2.CreateFromRaster(raster.Raster); //IMap map = ArcMap.Document.FocusMap; //map.AddLayer((ILayer)raster2); //MessageBox.Show(layerNameCombo.selected_layer_name + " " + raster2.RowCount + " " + raster2.ColumnCount + " " + raster2.BandCount); ColorSegmentationWorker cs = new ColorSegmentationWorker(); try { IRaster2 iraster2 = rasterlayer.Raster as IRaster2; string[] bitmap_fns = cs.Apply(System.IO.Path.GetDirectoryName(iraster2.RasterDataset.CompleteName) + "\\", ArcStrabo2Extension.Text_Result_Path + "\\", System.IO.Path.GetFileName(iraster2.RasterDataset.CompleteName)); IMap map = ArcMap.Document.FocusMap; foreach (string path in bitmap_fns) { //RasterDataset rds = new RasterDataset(); //rds.OpenFromFile(path); RasterLayer rasterlayer2 = new RasterLayer(); rasterlayer2.CreateFromFilePath(path); map.AddLayer(rasterlayer2); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }