+ pix = ComputeNumberOfPixels(image, GetForegroundValue());
+ double vol = image->GetSpacing()[0]*image->GetSpacing()[1]*image->GetSpacing()[2];
+ cc = pix * vol / (10*10*10);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+long vvToolSegmentation::ComputeNumberOfPixels(vvImage::Pointer image, double value)
+{
+ int n=0;
+ vtkImageData * im = image->GetFirstVTKImageData();
+ char * pPix = (char*)im->GetScalarPointer(); // FIXME char ?
+ for(uint i=0; i<im->GetNumberOfPoints(); i++) {
+ if (pPix[i] == value) n++;
+ }
+ DD(n);
+ return n;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolSegmentation::KeyPressed(std::string KeyPress)
+{
+ if (KeyPress == "e") {
+ Erode();
+ }
+ if (KeyPress == "d") {
+ Dilate(); // FIXME -> extend image BB !!
+ }
+ if (KeyPress == "L") {
+ Labelize();
+ }
+ if (KeyPress == "m") {
+ Merge();
+ UpdateAndRenderNewMask();
+ }
+ if (KeyPress == "s") { // Supress "Remove" one label
+ if (mCurrentState == State_CCL) RemoveLabel();
+ }
+ if (KeyPress == "t") { // display remove ref contour
+ mRefMaskActor->SetContourVisible(!mRefMaskActor->IsContourVisible());
+ mRefMaskActor->UpdateColor();
+ mCurrentSlicerManager->Render();
+ }
+ if (KeyPress == "w") {
+ vvImageWriter::Pointer writer = vvImageWriter::New();
+ writer->SetOutputFileName("a.mha");
+ writer->SetInput(mCurrentMaskImage);
+ writer->Update();
+ }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolSegmentation::Merge()
+{
+ if (mCurrentState != State_CCL) return;