[ITK] BinaryImageToShapeLabelMapFilter and vtk
Bradley Lowekamp
blowekamp at mail.nih.gov
Thu Jul 10 07:56:14 EDT 2014
Hello,
I think the itkLabelImageToAttributeImageFilter is what you are looking for.
If you look at the test you can see how to use it:
https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/LabelMap/test/itkLabelMapToAttributeImageFilterTest1.cxx
Brad
On Jul 10, 2014, at 5:54 AM, Michael Meuli <michael.meuli at gmail.com> wrote:
> 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;
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
More information about the Community
mailing list