[ITK] BinaryImageToShapeLabelMapFilter and vtk

Michael Meuli michael.meuli at gmail.com
Thu Jul 10 06:54:20 EDT 2014


Hi,
I am using itk::BinaryImageToShapeLabelMapFilter<itk::Image< unsigned char, 3 >>
For each object I get I'm calculating some mean value (below you can
see the relevant piece of code).
I would like to display these objects (bacteria) and color them
depending on that mean value in ParaView.
So I would like to write a freshly composed vtk file.
(In the end I have to count how many bacteria I have and how many of
them are digested within lysosomes.)

What would be the best way to do this? Could someone point be to some
more reading/examples?

Thanks a lot in advance,
best regards
Michael


  BinaryImageToShapeLabelMapFilterType::Pointer
binaryImageToShapeLabelMapFilter =
BinaryImageToShapeLabelMapFilterType::New();
  binaryImageToShapeLabelMapFilter->SetInput(binaryimage3Dbacteria);
  binaryImageToShapeLabelMapFilter->Update();
  unsigned int bacteriacount =
binaryImageToShapeLabelMapFilter->GetOutput()->GetNumberOfLabelObjects();
  unsigned int colcount = 0;
  for(unsigned int i = 0; i <
binaryImageToShapeLabelMapFilter->GetOutput()->GetNumberOfLabelObjects();
i++) {
    BinaryImageToShapeLabelMapFilterType::OutputImageType::LabelObjectType*
labelObject = binaryImageToShapeLabelMapFilter->GetOutput()->GetNthLabelObject(i);
    unsigned long long  pixelValue = 0;  //ImageType3D::PixelType
(16bit) was too short
    for(unsigned int pixelId = 0; pixelId < labelObject->Size(); pixelId++) {
      pixelValue += image3Dred->GetPixel( labelObject->GetIndex(pixelId) );
      }
    unsigned int mean = pixelValue / (labelObject->Size());
    std::cout << "Mean value in lysosomechannel of object " << i << ":
" << mean << std::endl;
    if ( mean > 100 ) {
      colcount++;
      }
    std::cout << std::endl;
    }
  std::cout << "Total bacteria counted: " << bacteriacount << std::endl;
  std::cout << "Bacteria colocalizing in lysosomechannel: " <<
colcount << std::endl;


More information about the Community mailing list