Hi Hannes,
in addition to Tobias' answer, multilabel segmentation images are of type
mitk::LabelSetImage [1].
Best,
Stefan
[1] http://docs.mitk.org/2016.11/classmitk_1_1LabelSetImage.html
Von: Stein, Tobias [mailto:t.st...@dkfz-heidelberg.de]
Gesendet: Monday, June 18, 2018 4:05 PM
An: hannes.bene...@gmx.de
Cc: mitk-users@lists.sourceforge.net
Betreff: Re: [mitk-users] Points from segmentation
Hi Hannes,
you can check the type of your image by using image->GetPixelType()
You should use the same return type of readAccess.GetPixelByIndex(idx) as you
chose for the ImagePixelReadAccessor.
Best,
Tobias
Von: hannes.bene...@gmx.de<mailto:hannes.bene...@gmx.de>
[mailto:hannes.bene...@gmx.de]
Gesendet: Montag, 18. Juni 2018 15:40
An: Stein, Tobias
<t.st...@dkfz-heidelberg.de<mailto:t.st...@dkfz-heidelberg.de>>
Betreff: AW: [mitk-users] Points from segmentation
Hey Tobias,
so i tried to get the segmentation points, but i couldn't achieve it at all. I
figuered out how to access the data storage and get the data node of a new
segmentation node (labelsetimage). But when i try to acces the image, my
program crashes. I'm trying with two attempts but none oft hem works. Only the
second attempt gets through point 2.1 but the crashes as well.
So wich is the right pixeltype for a labelsetimage? What am i doing wrong in
here?
Best regards,
Hannes
void DrillHoleSegmentation::GetRawSegmentation()
{
// acces the data storage
QList<mitk::DataNode::Pointer> nodes = this->GetDataManagerSelection();
if (nodes.empty())
return;
mitk::DataNode *node = nodes.front();
if (!node)
{
// Nothing selected. Inform the user and return
QMessageBox::information(NULL, "Template", "Please load and select an
image before starting image processing.");
return;
}
mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(node->GetData());
// access the raw image data
try
{
itk::Index<3> idx = {{ 1, 1, 1 }};
mitk::ImagePixelReadAccessor<uint16_t,3> readAccess(image,
image->GetSliceData(2));
std::cout << "step 1.1..OK " << std::endl;
double value = readAccess.GetPixelByIndex(idx);
std::cout << "step 1.2..OK...value: " << value << std::endl;
}
catch(mitk::Exception& e)
{
// deal with the situation not to have access
std::cout << "no acces to image data " << std::endl;
}
// another attempt
try
{
float coords[3]={1.0,1.0,1.0};
mitk::Point3D position(coords);
mitk::ImagePixelReadAccessor<uint16_t,3> readAccess(image);
std::cout << "step 2.1..OK " << std::endl;
double value = readAccess.GetPixelByWorldCoordinates(position);
std::cout << "step 2.2..OK..value 2: " << value << std::endl;
}
catch(mitk::Exception& e)
{
// deal with the situation not to have access
std::cout << "no acces to image data v 2 " << std::endl;
}
// iterate through all pixels and check if the value is 0 or 1 (binary
image)
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users