Hey everyone,
I#m trying to get the coordinates of all pixels from a new segmentation.
What I achieved so far is to get the node from the data manager and I also
could iterate through all the points oft the segmentation to check if its 0
or not. However this takes quite a lot of time and even gives me wrong
values or NaN when i try to work with these coordinates of the values. So
now I try to get only the shown segmentation where only the existing points
are included. My problem is, that i cant acces the label properly. My
attempt so far:
mitk::LabelSetImage *lsi =
dynamic_cast<mitk::LabelSetImage*>(node->GetData());
// just collecting some data
unsigned int labels = lsi->GetTotalNumberOfLabels();
std::cout << "Total number of Labels: " << labels << std::endl; // 2
labels
std::cout << "number of Labels layer 0: " << lsi->GetNumberOfLabels(0)
<< std::endl; // 2
std::cout << "number of Labels layer 1: " << lsi->GetNumberOfLabels(1)
<< std::endl; // 3446705496 (changes with every new segmentation)
//std::cout << "number of labels layer 2: " << lsi->GetNumberOfLabels(2)
<< std::endl; // crash
std::cout << "number of layer: " << lsi->GetNumberOfLayers() <<
std::endl; // 1
std::cout << "number of channels " << lsi->GetNumberOfChannels() <<
std::endl; // 1
const mitk::PixelType type = lsi->GetPixelType();
std::cout << "image type: " << type.GetPixelTypeAsString() << std::endl;
// this doesnt work
// iterate through all pixels the old way
unsigned int maxx = lsi->GetDimension(0);
unsigned int maxy = lsi->GetDimension(1);
unsigned int maxz = lsi->GetDimension(2);
Eigen::MatrixXd matb(1,3);
double point[3];
//read in all of the points and write to matrix
uint32_t neuerzaehlerb = 0;
/* for (unsigned int a = 0; a < maxx; a++){
for (unsigned int b = 0; b < maxy; b++){
for (unsigned int c = 0; c < maxz; c++){
itk::Index<3> idx = {{ a, b, c }};
double pt = lsi->GetPixelValueByIndex(idx);
if (pt != 0){
point[0] = static_cast<double>(a);
point[1] = static_cast<double>(b);
point[2] = static_cast<double>(c);
if ( isnan(point[0]) == false || isnan(point[1]) ==
false || isnan(point[2] == false) ) {
matb.resize(neuerzaehlerb+2,3);
matb(neuerzaehlerb,0)=point[0];
matb(neuerzaehlerb,1)=point[1];
matb(neuerzaehlerb,2)=point[2];
//std::cout << "mat zeile: " << neuerzaehlerb << " :
" << matb.row(neuerzaehlerb) << std::endl;
neuerzaehlerb++;
}
}
}
}
}
// trying to get only the points from the segmentation that are already
1
mitk::Label lab = lsi->GetLabel();
mitk::Point3D cent = lab.GetCenterOfMassIndex();
std::cout << "label 1 center of mass index " << cent << std::endl;
So maybe you guys have an idea what i should be looking for?
Best regards,
Hannes
------------------------------------------------------------------------------
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