private void ToolStripMenuItem_DisplayImage(object sender, EventArgs e) { List<cImageMetaInfo> ListInfo = cGlobalInfo.ImageAccessor.GetImageInfo(this); cImage Image = new cImage(ListInfo); this.BD_BoxMax.Z = this.BD_BoxMin.Z = 0; // this.BD_BoxMin.Y = Image.Height - this.BD_BoxMin.Y; // this.BD_BoxMax.Y = Image.Height - this.BD_BoxMax.Y; if (this.BD_BoxMin.Y > this.BD_BoxMax.Y) { double Tmp = this.BD_BoxMin.Y; this.BD_BoxMin.Y = this.BD_BoxMax.Y; this.BD_BoxMax.Y = Tmp; } cImage CroppedImaged = Image.Crop(this.BD_BoxMin, this.BD_BoxMax); cDisplaySingleImage IV = new cDisplaySingleImage(); IV.IsUseSavedDefaultDisplayProperties = true; IV.DefaultZoom = 100; IV.Title = "[Plate] " + this.AssociatedWell.AssociatedPlate.GetName() + " - [Well] " + this.AssociatedWell.GetPos() + " - [Field] " + this.ImageField + " - " + this.CellularPhenotypeType.Name; IV.SetInputData(CroppedImaged); IV.Run(); }
public cFeedBackMessage Run(c3DNewWorld _3DWorld) { if (base.Start() == false) { base.FeedBackMessage.IsSucceed = false; return base.FeedBackMessage; } #region Properties Management object _firstValue = base.ListProperties.FindByName("Thresold"); double Thresold = 0.5; if (_firstValue == null) { base.GenerateError("-Thresold- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; Thresold = (double)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Thresold- cast didn't work"); return base.FeedBackMessage; } _firstValue = base.ListProperties.FindByName("Split objects ?"); bool IsSplit = false; if (_firstValue == null) { base.GenerateError("-Split objects ?- not found !"); return base.FeedBackMessage; } try { cProperty TmpProp = (cProperty)_firstValue; IsSplit = (bool)TmpProp.GetValue(); } catch (Exception) { base.GenerateError("-Split objects ?- cast didn't work"); return base.FeedBackMessage; } #endregion ListObjects = new cListGeometric3DObject(""); if (IsSplit == false) { c3DMeshObject MyMesh = null; if (this.VTKInput == null) { MyMesh = new c3DMeshObject(this.Input, Thresold); } else { MyMesh = new c3DMeshObject(this.VTKInput, (int)Thresold); } MyMesh.Create(Color.Aqua, this.Pos ); ListObjects.Name = MyMesh.GetName() + " metaobject"; ListObjects.Add(MyMesh); } else { // ok that's a little bit more complicated now // first we need to binarize the image cImageSegmentationThreshold IST = new cImageSegmentationThreshold(); IST.ListProperties.FindByName("Threshold").SetNewValue(Thresold); cImage SourceImage = new cImage(this.Input, false); IST.SetInputData(SourceImage); IST.Run(); // now perform image labeling cImage BinImage = IST.GetOutPut(); cImage LabeledImage = new cImage(BinImage, false); ConnectedComponentSet CCS = new ConnectedComponentSet(BinImage,LabeledImage,SourceImage, 0, eConnectivity.THREED_6, 0, float.MaxValue); Random RD = new Random(); int IdxObj = 1; // loop over each object int NumObj = CCS.Count; ListObjects.Name = "T_" + Thresold + " [" + SourceImage.Name + " Metaobject"; for(int i = 0;i<NumObj;i++) { ConnectedVoxels item = CCS[i]; // if (item.Volume <= 1) continue; List<cPoint3D> ExtremePts = item.GetExtremaPoints(); // crop the labeled image cImage TmpIm = LabeledImage.Crop(ExtremePts[0], ExtremePts[1]); // we have to clean the cropped image to prevent any overlapping object to be segmented for (int Pix = 0; Pix < TmpIm.ImageSize; Pix++) { if ((TmpIm.SingleChannelImage[0].Data[Pix] > 0) && (TmpIm.SingleChannelImage[0].Data[Pix] != IdxObj)) TmpIm.SingleChannelImage[0].Data[Pix] = 0; } // update the position of the object cPoint3D NewPos = ExtremePts[0]*SourceImage.Resolution; c3DMeshObject MyMesh = new c3DMeshObject(TmpIm.SingleChannelImage[0], 0.5); MyMesh.Create(Color.FromArgb(RD.Next(255), RD.Next(255), RD.Next(255)), NewPos); MyMesh.SetName(MyMesh.GetName() + "_" + IdxObj); MyMesh.AssociatedConnectedComponent = item; ListObjects.AddObject(MyMesh); IdxObj++; } } return base.FeedBackMessage; }
private void TSItemSubPopSelectionDataTableImages(object sender, EventArgs e) { ToolStripMenuItem ParentTag = (ToolStripMenuItem)(sender); List<int> MyList = ((List<int>)(ParentTag.Tag)); cExtendedTable ET = new cExtendedTable(this.InputSimpleData.Count, MyList.Count, 0); for (int i = 0; i < this.InputSimpleData.Count; i++) { ET[i].Name = this.InputSimpleData[i].Name; } ET.ListRowNames = new List<string>(); for (int i = 0; i < MyList.Count; i++) { ET.ListRowNames.Add(i.ToString()); } if (this.InputSimpleData.ListTags != null) ET.ListTags = new List<object>(); int IdxPt = 0; FormForProgress FP = new FormForProgress(); FP.Show(); int MaxProgress = MyList.Count; FP.progressBar.Maximum = MaxProgress; foreach (var item in MyList) { for (int i = 0; i < this.InputSimpleData.Count; i++) { ET[i][IdxPt] = this.InputSimpleData[i][MyList[IdxPt]]; } if ((this.InputSimpleData.ListTags != null) && (this.InputSimpleData.ListTags[IdxPt] != null)) { if (this.InputSimpleData.ListTags[MyList[IdxPt]].GetType() == typeof(cSingleBiologicalObject)) { cSingleBiologicalObject TmpBioObj = ((cSingleBiologicalObject)this.InputSimpleData.ListTags[MyList[IdxPt]]); List<cImageMetaInfo> ListMeta = cGlobalInfo.ImageAccessor.GetImageInfo(TmpBioObj); if (ListMeta==null) continue; cImage Image = new cImage(ListMeta); TmpBioObj.BD_BoxMax.Z = TmpBioObj.BD_BoxMin.Z = 0; cImage CroppedImaged = Image.Crop(TmpBioObj.BD_BoxMin, TmpBioObj.BD_BoxMax); if((cGlobalInfo.TmpImageDisplayProperties==null)||(cGlobalInfo.TmpImageDisplayProperties.ListMin.Count != CroppedImaged.GetNumChannels())) { ET.ListTags.Add(CroppedImaged.GetBitmap(1f, null, null)); } else { cImageDisplayProperties IP = cGlobalInfo.TmpImageDisplayProperties; ET.ListTags.Add(CroppedImaged.GetBitmap(1f, IP, null)); } FP.richTextBoxForComment.AppendText("Object "+ IdxPt +" / "+MyList.Count +"\n"); } } FP.progressBar.Value = IdxPt; FP.Refresh(); IdxPt++; } FP.Close(); ET.Name = "Data Table - " + MyList.Count + " Objects"; cDisplayExtendedTable DET = new cDisplayExtendedTable(); DET.SetInputData(ET); DET.Run(); //DataPoint DP = new DataPoint(); //if (this.InputSimpleData[0].ListTags != null) //{ // if (j >= this.InputSimpleData[0].ListTags.Count) continue; // DP.Tag = this.InputSimpleData[0].ListTags[j]; // // if (DP.Tag.GetType() == typeof(cWell)) // // { // // DP.Color = ((cWell)(DP.Tag)).GetClassColor(); // // DP.ToolTip = ((cWell)(DP.Tag)).GetShortInfo() + Value[0]; // // } // if (DP.Tag.GetType() == typeof(cSingleBiologicalObject)) // { // // DP.Color = ((cSingleBiologicalObject)(DP.Tag)).GetColor(); // // DP.ToolTip = ((cSingleBiologicalObject)(DP.Tag)).GetAssociatedPhenotype().Name + "\nValue: (" + DP.XValue.ToString("N2") + ":" + DP.YValues[0].ToString("N2") + ")"; // } //} }
private void ToolStripMenuItem_DisplayImages(object sender, EventArgs e) { //if (cWell.cGlobalInfo.ImageAccessor.ImagingPlatformType == HCSAnalyzer.Classes.General_Types.eImagingPlatformType.OPERETTA) return; cGlobalInfo.ImageAccessor.Field = 1;// (int)this.numericUpDownField.Value; //string FileName = cWell.cGlobalInfo.ImageAccessor.GetImageFileName(this); foreach (cWell item in this.ListActiveWells) { List<cImageMetaInfo> ListMetaInfo = cGlobalInfo.ImageAccessor.GetImageInfo(item); cImage Image = new cImage(ListMetaInfo); Image.Name = "Image [" + item.GetShortInfo() + "] - Field [" + cGlobalInfo.ImageAccessor.Field + "]"; cImage FinaleImage = Image.Crop(new cPoint3D(400, 400, 0), new cPoint3D(800 + 400, 800 + 400, 0)); //cImageGeometricResize IR = new cImageGeometricResize(); //IR.SetInputData(Image); //IR.InterpolationType = Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR; //IR.ListProperties.UpdateValueByName("Scale", (double)0.25); //IR.Run(); //cImage FinaleImage = IR.GetOutPut(); //FinaleImage.Name = "Image [" + item.GetShortInfo()+"] - Field ["+ cWell.cGlobalInfo.ImageAccessor.Field + "]"; cDisplaySingleImage IV = new cDisplaySingleImage(); IV.SetInputData(FinaleImage); IV.Run(); } //cImage IM = new cImage(this.Info); //if (IM == null) return; //cImageViewer IV = new cImageViewer(); //IV.SetImage(IM); //IV.Show(); //cViewerImage3D VI3D = new cViewerImage3D(); //foreach (cWell item in this.ListActiveWells) //{ // vtkJPEGReader JPEGReader = vtkJPEGReader.New(); // JPEGReader.SetFileName(item.Info); // JPEGReader.Update(); // vtkImageData ID0 = JPEGReader.GetOutput(); // VI3D.SetInputData(ID0); //} //// cVolume3D Volume3D0 = new cVolume3D(ID0, new HCSAnalyzer.Classes._3D.cPoint3D(0, 0, 0)); //VI3D.Run(); //cDisplayToWindow DTW = new cDisplayToWindow(); //DTW.SetInputData(VI3D.GetOutPut()); //DTW.Run(); //DTW.Display(); }