private void AnalyseSequence(cImage SeqToAnalyse) { // //FormForThumbnails WindThumbnail = new FormForThumbnails(); // //for (int k = 0; k < ListFormForControl.Count; k++) // //{ // // FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k-1); // // Obj.DisplayThumbnail(WindThumbnail); // //} // //WindThumbnail.Show(); // //return; #region initialization if (SeqToAnalyse == null) return; // create World if (Current3DWorld == null) { Current3DWorld = new c3DNewWorld(new cPoint3D(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth), new cPoint3D(SeqToAnalyse.Resolution)); } else { // // Current3DWorld.ren1. // Current3DWorld.Terminate(); Current3DWorld = null; Current3DWorld = new c3DNewWorld(new cPoint3D(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth), new cPoint3D(SeqToAnalyse.Resolution)); } for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k-1); if (Obj.numericUpDownChannel.Value >= SeqToAnalyse.GetNumChannels()) { MessageBox.Show("Wrong number of channels", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // // Current3DWorld.ListObjControl = ListFormForControl; // // dataGridViewForClassif.DataSource = CurrentTable; // if (DataGrid == null) // { // DataGrid = new FormForDataGridView(); // DataGrid.Show(); // } // Current3DWorld.SetLinkToDataGridView(DataGrid.dataGridViewForResults); Current3DWorld.ListMetaObjectList = new List<cMetaBiologicalObjectList>(); cMetaBiologicalObjectList ListMetacells = new cMetaBiologicalObjectList("List Meta Objects"); Current3DWorld.ListMetaObjectList.Add(ListMetacells); #endregion #region Detection for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k -1); if (Obj.radioButtonIsVolume.Checked) // we have to detect a volume ! { cVolumeDetection Detection = new cVolumeDetection(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value, Obj.WindowForVolumeDetection.checkBoxIsBorderKill.Checked); Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); if ((Obj.checkBoxPreProcessings.Checked == false) || (Obj.WindowForPreProcessing.checkBoxMedianIsDisabled.Checked)) { Detection.SetMedian(-1); Detection.SetShift(new cPoint3D(0, 0, 0)); } else { Detection.SetMedian((int)Obj.WindowForPreProcessing.numericUpDownMedianKernel.Value); Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); } if (Obj.WindowForVolumeDetection.checkBoxVolumeSmooth.Checked) Detection.MeshSmoother = new cMeshSmoother((int)Obj.WindowForVolumeDetection.numericUpDownSmoothIterations.Value); if ((Obj.comboBoxContainer.SelectedItem !=null) && (Obj.comboBoxContainer.SelectedItem.ToString() != "")) { Detection.SetContainers(Current3DWorld.GetListBiologicalObjectsOfType(Obj.comboBoxContainer.Items[0].ToString())); if (Obj.InOrOut.radioButtonIn.Checked) Detection.SetContainersMode(0); else Detection.SetContainersMode(1); } else Detection.SetContainers(null); if (Obj.WindowForVolumeDetection.checkBoxIsRegionGrowing.Checked == false) // no region growing direct detection { Obj.AssociatedBiologicalObjectList = Detection.IntensityThreshold((float)Obj.WindowForVolumeDetection.numericUpDownIntensityThreshold.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value); } else // region growing { if (Obj.WindowForVolumeDetection.radioButtonRegionsBased.Checked) // start from a segmentation { if (Obj.WindowForVolumeDetection.radioButtonVolumeDetectionNew.Checked) // a new segmentation has to be performed { // // Image3D CurrentPatch = new Image3D(2 * Radius, 2 * Radius, 1, CurrentImageToProcess.NumBands); cImage CurrentBinary = new cImage(SeqToAnalyse.Width, SeqToAnalyse.Height, SeqToAnalyse.Depth, 1); for (int i = 0; i < CurrentBinary.ImageSize; i++) { if (SeqToAnalyse.SingleChannelImage[(int)Obj.numericUpDownChannel.Value].Data[i] >= (float)Obj.WindowForVolumeDetection.numericUpDownIntensityThreshold.Value) CurrentBinary.SingleChannelImage[0].Data[i] = 1; } eConnectivity CurrentConnectivity = eConnectivity.TWOD_4; if (CurrentBinary.Depth > 1) CurrentConnectivity = eConnectivity.THREED_6; ConnectedComponentSet OFNucleus = new ConnectedComponentSet(CurrentBinary, null, null, 0, CurrentConnectivity, (int)Obj.WindowForVolumeDetection.numericUpDownRegionBasedMinArea.Value, (int)Obj.WindowForVolumeDetection.numericUpDownRegionBasedMaxArea.Value); // // RegionGrowing = new cRegionGrowing(OFNucleus, NewSeq[0], (int)numericUpDownChannelForRegionGrowing.Value, (float)numericUpDownIntensityForRegionGrowing.Value, (int)numericUpDownMaxNucleusArea.Value); int NumIterations = -1; if (Obj.WindowForVolumeDetection.checkBoxIsConvergence.Checked == false) NumIterations = (int)Obj.WindowForVolumeDetection.numericUpDownIterationNumber.Value; float MergingRatio = (float)((Obj.WindowForVolumeDetection.trackBarMergingStrength.Maximum - Obj.WindowForVolumeDetection.trackBarMergingStrength.Value) / 100.0); Obj.AssociatedBiologicalObjectList = Detection.RegionGrowing(OFNucleus, (float)Obj.WindowForVolumeDetection.numericUpDownIntensityForRegionGrowing.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value, (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value, NumIterations, MergingRatio); } // else // { // throw new System.ArgumentException("Not implemented", "Error"); // } // } // else // start from seeds points // { // // first gather the seeds // if (Obj.WindowForVolumeDetection.comboBoxExistingSpotsDetected.Items.Count == 0) break; // List<cBiological3DObject> ListSeeds = Current3DWorld.GetListBiologicalObjectsOfType(Obj.WindowForVolumeDetection.comboBoxExistingSpotsDetected.Items[0].ToString()); // int NumIterations = -1; // if (Obj.WindowForVolumeDetection.checkBoxIsConvergence.Checked == false) NumIterations = (int)Obj.WindowForVolumeDetection.numericUpDownIterationNumber.Value; // float MergingRatio = (float)((Obj.WindowForVolumeDetection.trackBarMergingStrength.Maximum - Obj.WindowForVolumeDetection.trackBarMergingStrength.Value) / 100.0); // Obj.AssociatedBiologicalObjectList = Detection.RegionGrowing(ListSeeds, // (float)Obj.WindowForVolumeDetection.numericUpDownIntensityForRegionGrowing.Value, // (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMinVol.Value, // (float)Obj.WindowForVolumeDetection.numericUpDownVolumeMaxVol.Value, NumIterations, MergingRatio); } } if (Obj.AssociatedBiologicalObjectList != null) { Obj.richTextBoxInfo.AppendText(Obj.AssociatedBiologicalObjectList.Count + " objects detected."); for (int i = 0; i < Obj.AssociatedBiologicalObjectList.Count; i++) { cBiological3DVolume TmpVol = (cBiological3DVolume)Obj.AssociatedBiologicalObjectList[i]; Obj.AssociatedBiologicalObjectList[i].SetType(Obj.textBoxName.Text); // TmpVol.ThumbnailnewImage = imageListForThumbnail.Images[Obj.AssociatedBiologicalObjectList[i].GetType() + ".jpg"]; Obj.AssociatedBiologicalObjectList[i].Name = Obj.textBoxName.Text + " " + i; // Obj.AssociatedBiologicalObjectList[i].IsMaster = Obj.IsMasterObject(); // List<double> Res = TmpVol.Information.GetInformation(); if (Obj.checkBoxIsDisplayName.Checked) { cGeometric3DObject AssociatedText = TmpVol.AttachText(TmpVol.Name, 10, Color.White); AssociatedText.IsStayInFrontOfCamera = true; Current3DWorld.AddGeometric3DObject(AssociatedText); // TmpVol.AddText(TmpVol.Name, Current3DWorld, (double)Obj.ForText.numericUpDownArrowScale.Value, Obj.ForText.buttonChangeColorPositive.BackColor); } if (Obj.checkIsBoxPointingArrow.Checked) { cGeometric3DObject AssociatedArrow = TmpVol.AttachPointingArrow((double)Obj.ForArrow.numericUpDownArrowScale.Value, Obj.ForArrow.buttonChangeColorPositive.BackColor); Current3DWorld.AddGeometric3DObject(AssociatedArrow); } Obj.AssociatedBiologicalObjectList[i].SetOpacity((double)Obj.ColorOpacity.numericUpDownValue.Value); // if the object it the Master then create a meta-object and put it inside if (Obj.IsMasterObject()) { cMetaBiologicalObject Cell = new cMetaBiologicalObject(Obj.WindowForMaster.textBoxName.Text + i, Current3DWorld.ListMetaObjectList[0], Obj.AssociatedBiologicalObjectList[i]); // // Cell.AddObject(Obj.AssociatedBiologicalObjectList[i]); Current3DWorld.ListMetaObjectList[0].Add(Cell); } } if (Obj.radioButtonColorSingle.Checked) Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Regular); else if (Obj.radioButtonColorRandom.Checked) Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Random); else if (Obj.radioButtonColorIndexed.Checked) Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Indexed); } } else if (Obj.RadioButtonIsSpot.Checked) { cSpotDetection Detection = new cSpotDetection(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value); if ((Obj.checkBoxPreProcessings.Checked == false) || (Obj.WindowForPreProcessing.checkBoxMedianIsDisabled.Checked)) { Detection.SetMedian(-1); Detection.SetShift(new cPoint3D(0, 0, 0)); } else { Detection.SetMedian((int)Obj.WindowForPreProcessing.numericUpDownMedianKernel.Value); Detection.SetShift(new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); } if ((Obj.comboBoxContainer.Items.Count > 0) && (Obj.comboBoxContainer.SelectedItem != null)) { Detection.SetContainers(Current3DWorld.GetListBiologicalObjectsOfType(Obj.comboBoxContainer.SelectedItem.ToString())); if (Obj.InOrOut.radioButtonIn.Checked) Detection.SetContainersMode(0); else Detection.SetContainersMode(1); } Obj.AssociatedBiologicalObjectList = Detection.HessianDetection((float)Obj.WindowForSpotDetection.numericUpDownSpotRadius.Value, (float)Obj.WindowForSpotDetection.numericUpDownIntensityThreshold.Value, (int)Obj.WindowForSpotDetection.numericUpDownSpotLocality.Value, (double)Obj.WindowForSpotDetection.numericUpDownSphereDisplayRadius.Value); Obj.richTextBoxInfo.AppendText(Obj.AssociatedBiologicalObjectList.Count + " objects detected."); for (int i = 0; i < Obj.AssociatedBiologicalObjectList.Count; i++) { cBiologicalSpot TmpSpot = (cBiologicalSpot)Obj.AssociatedBiologicalObjectList[i]; TmpSpot.Name = Obj.textBoxName.Text + " " + i; TmpSpot.SetType(Obj.textBoxName.Text); // TmpSpot.ThumbnailnewImage = imageListForThumbnail.Images[Obj.AssociatedBiologicalObjectList[i].GetType() + ".jpg"]; // if (Obj.checkBoxIsDisplayName.Checked) // TmpSpot.AddText(TmpSpot.Name, Current3DWorld, (double)Obj.ForText.numericUpDownArrowScale.Value, Obj.ForText.buttonChangeColorPositive.BackColor); if (Obj.checkIsBoxPointingArrow.Checked) { cGeometric3DObject AssociatedArrow = TmpSpot.AttachPointingArrow((double)Obj.ForArrow.numericUpDownArrowScale.Value, Obj.ForArrow.buttonChangeColorPositive.BackColor); Current3DWorld.AddGeometric3DObject(AssociatedArrow); } // TmpSpot.SetOpacity((double)Obj.ColorOpacity.numericUpDownValue.Value); // // if the object it the Master then create a meta-object and put it inside if (Obj.IsMasterObject()) { cMetaBiologicalObject Cell = new cMetaBiologicalObject("Cell " + i, Current3DWorld.ListMetaObjectList[0], Obj.AssociatedBiologicalObjectList[i]); // // Cell.AddObject(Obj.AssociatedBiologicalObjectList[i]); Current3DWorld.ListMetaObjectList[0].Add(Cell); } // /*cMetaBiologicalObject Cell = */ // //Current3DWorld.ListMetaObjectList[0].AssociateWith(Current3DWorld.ListMetaObjectList[0].FindTheClosestVolumeFrom(TmpSpot.GetCentroid(), 20), TmpSpot); } // if (Obj.radioButtonColorSingle.Checked) // Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Regular); // else if (Obj.radioButtonColorRandom.Checked) // Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Random); // else if (Obj.radioButtonColorIndexed.Checked) // Current3DWorld.AddBiological3DObjects(Obj.AssociatedBiologicalObjectList, Obj.buttonChangeColorPositive.BackColor, eColorMode.Indexed); } else if (Obj.radioButtonIsVolumeRendering.Checked) { Current3DWorld.AddVolume3D(new cVolumeRendering3D(this.AssociatedImage.SingleChannelImage[(int)Obj.numericUpDownChannel.Value], new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value), null, Current3DWorld)); // cVolume3D Volume = new cVolume3D(SeqToAnalyse, (int)Obj.numericUpDownChannel.Value, new cPoint3D((float)Obj.WindowForPreProcessing.numericUpDownShiftX.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftY.Value, (float)Obj.WindowForPreProcessing.numericUpDownShiftZ.Value)); // Current3DWorld.AddVolume3D(Volume, Color.Black, Obj.buttonChangeColorPositive.BackColor); } // Thread oThread = new Thread(new ThreadStart(Obj.DisplayDone)); } #endregion #region Objects Association cMetaBiologicalObjectList MetaCellList = Current3DWorld.ListMetaObjectList[0]; // let's associate the objects for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k -1); // that's a volume rendering ... no connection if (Obj.radioButtonIsVolumeRendering.Checked) continue; // the object is the master if (Obj.IsMasterObject()) continue; // this object has not connections ... is not associated to the master if (Obj.comboBoxLinkToTheMaster.SelectedIndex == 0) continue; cPoint3D ClosestPt = new cPoint3D(0, 0, 0); foreach (cBiological3DVolume CurrentSubObj in Obj.AssociatedBiologicalObjectList) { cBiological3DVolume ObjectToIdentify = null; switch (Obj.comboBoxLinkToTheMaster.SelectedIndex) { case 1: // association by distance to the master centroid ObjectToIdentify = MetaCellList.FindTheClosestVolumeCentroidFrom(CurrentSubObj.GetCentroid(), (double)Obj.WindowDistanceToMaster.numericUpDownDistanceMaxToMaster.Value); break; case 2: // //cBiological3DVolume CurrentVolume ObjectToIdentify = MetaCellList.FindTheClosestVolumeFrom(CurrentSubObj, (double)Obj.WindowDistanceToMaster.numericUpDownDistanceMaxToMaster.Value, out ClosestPt); break; default: break; } if (ObjectToIdentify == null) continue; cMetaBiologicalObject Cell = MetaCellList.AssociateWith(ObjectToIdentify, CurrentSubObj); // // -------------- draw information and links between the objects --------------------- if (Obj.WindowDistanceToMaster.checkBoxDrawLinkToMasterCenter.Checked) { c3DLine CurrLine = new c3DLine(CurrentSubObj.GetCentroid(), ObjectToIdentify.GetCentroid()); Current3DWorld.AddGeometric3DObject(CurrLine); //if (Obj.WindowDistanceToMaster.checkBoxDisplayBranchToCenterDistance.Checked) // CurrLine.DisplayLenght(Current3DWorld, 0.4); } // // -------------- draw information and links between the objects --------------------- if (Obj.WindowDistanceToMaster.checkBoxDrawLinkToMasterEdges.Checked) { c3DLine CurrLine1 = new c3DLine(CurrentSubObj.GetCentroid(), ClosestPt); Current3DWorld.AddGeometric3DObject(CurrLine1); //if(Obj.WindowDistanceToMaster.checkBoxDisplayBranchToEdgesDistance.Checked) // CurrLine1.DisplayLenght(Current3DWorld, 0.4); } } } #endregion #region Post Processings for (int k = 0; k < ListFormForControl.Count; k++) { FormForControl Obj = ListFormForControl.ElementAt(ListFormForControl.Count - k - 1); // the object is the master // // if (!Obj.IsMasterObject()) continue; if (!Obj.WindowForMaster.checkBoxDrawAssociatedDelaunay.Checked) continue; foreach (cMetaBiologicalObject CurrentMeta in MetaCellList) { Current3DWorld.AddGeometric3DObject(CurrentMeta.GenerateDelaunay(2.0f,true)); } } if (PostProcessWindow.checkBoxRemoveUnAssociatedObjects.Checked) { int RemovedObjects = Current3DWorld.RemoveNonAssociatedObjects(); Console.WriteLine(RemovedObjects + " objects removed."); } // if (PostProcessWindow.checkBoxExportMetaObjectSignatures.Checked) // { // if (CurrentTable == null) // { // CurrentTable = new DataTable(); // if (CurrentExperiment == null) // CurrentTable.Columns.Add(new DataColumn("Image Idx", typeof(int))); // else // { // CurrentTable.Columns.Add(new DataColumn("Image Col.", typeof(int))); // CurrentTable.Columns.Add(new DataColumn("Image Row", typeof(int))); // } // CurrentTable.Columns.Add(new DataColumn("Meta Object Name", typeof(string))); // foreach (string DescName in MetaCellList[0].GetSignatureNames()) // CurrentTable.Columns.Add(new DataColumn(DescName, typeof(double))); // CurrentTable.Columns.Add(new DataColumn("Class", typeof(double))); // } // foreach (cMetaBiologicalObject CurrentMeta in MetaCellList) // { // List<double> CurrentSignature = CurrentMeta.GetSignature(); // CurrentTable.Rows.Add(); // if (CurrentExperiment == null) // { // CurrentTable.Rows[CurrentTable.Rows.Count - 1][0] = IdxImageProcessed; // CurrentTable.Rows[CurrentTable.Rows.Count - 1][1] = CurrentMeta.Name; // for (int Idx = 0; Idx < CurrentSignature.Count; Idx++) // CurrentTable.Rows[CurrentTable.Rows.Count - 1][Idx + 2] = CurrentSignature[Idx]; // } // else // { // CurrentTable.Rows[CurrentTable.Rows.Count - 1][0] = CurrentExperiment.Column; // CurrentTable.Rows[CurrentTable.Rows.Count - 1][1] = CurrentExperiment.Row; // CurrentTable.Rows[CurrentTable.Rows.Count - 1][2] = CurrentMeta.Name; // for (int Idx = 0; Idx < CurrentSignature.Count; Idx++) // CurrentTable.Rows[CurrentTable.Rows.Count - 1][Idx + 3] = CurrentSignature[Idx]; // } // // Current3DWorld.CopyMetaObjectSignatureToTable(CurrentMeta, 0); // } // if (DataGrid != null) // { // DataGrid.dataGridViewForResults.DataSource = CurrentTable; // DataGrid.Update(); // IdxImageProcessed++; // } // } #endregion // //CurrentTable = new DataTable(); // if (CurrentExperiment == null) // { // if (PostProcessWindow.checkBoxDisplayBottomPlate.Checked) Current3DWorld.DisplayBottom(Color.FromArgb(255, 255, 255)); // Current3DWorld.SetBackgroundColor(PostProcessWindow.buttonChangeColorPositive.BackColor); // Current3DWorld.Render(); // } // // Current3DWorld.SetLinkToDataGridView(dataGridViewForClassif); cViewer3D V3D = new cViewer3D(); V3D.SetInputData(Current3DWorld); V3D.Run(); cDisplayToWindow DTW = new cDisplayToWindow(); DTW.SetInputData(V3D.GetOutPut()); DTW.Run(); DTW.Display(); }
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; }