Hi Joseph!
Thanks for your quick reply!
I'm not really sure if it's better to use itk or mitk. But as far as I can see,
it's not possible to use the mitk accessors without knowing the data type at
compilation time. So I'll decide on using itk. I'm now doing this, which works
very well:
float coords[3]={100,100,100};
mitk::Point3D position(coords);
IndexType idx;
imageGeometry->WorldToIndex( position, idx);
TPixel pixelValue=itkImage->GetPixel(idx);
cout<<"pixel value at 100,100,100 = "<<pixelValue<<endl;
This gives me the value at the corresponding world coordinates in mm, which is
actually very convenient for me. Is this always interpolating in mm?
So the next step would then be to iterate just like this:
for(int i=0;i<xsize;i++){
coords[0]=i;
for(int j=0;j<ysize;j++) {
coords[1]=j;
for(int k=0;k<number_of_slices;k++) {
coords[2]=k;
//do something
}}}
How can I reinitialize a new point? Or is there a way to just change single
coordinates in the mitk::Point3D variable?
Best Regards,
Martin
________________________________
Von: "Görres, Joseph" <[email protected]>
An: 'Martin Tatzber' <[email protected]>;
"[email protected]" <[email protected]>
Gesendet: 13:16 Dienstag, 12.März 2013
Betreff: AW: [mitk-users] get pixel values
Hi Martin,
At first you should decide if you want to work with itk or with mitk images. If
you want to work with the mitk::Image class, ImageAccessors are the best way to
access pixels by index. The concept of ImageAccessors
(including the ImagePixelReadAccessor) is explained on
http://docs.mitk.org/2012.12/MitkImagePage.html#MitkImagePage_AccessImageData.
You get compiler errors, because you cannot call GetPixelByWorldCoordinates
without having an object of ImagePixelReadAccessor. Your code should look like
this:
mitk::ImagePixelReadAccessor<TPixel,VDimension> readAccess(image);
TPixel value = readAccess.GetPixelByWorldCoordinates(point3d)
However, if you want to work with the itk::Image class, you should use image
access methods provided by itk.
Best Regards,
Joseph
-------------------------------------------------
Von: Martin Tatzber [mailto:[email protected]]
Gesendet: Dienstag, 12. März 2013 12:17
An: [email protected]
Betreff: [mitk-users] get pixel values
Hi!
I have a DICOM image and now want to go through all pixels to get their values.
How can I do this best?
In the region grower from the tutorial, pixel values are read like this:
// convert world coordinates to image indices
imageGeometry->WorldToIndex( pointsIterator.Value(), seedIndex);
// get the pixel value at this point
TPixel currentPixelValue = itkImage->GetPixel( seedIndex );
Is it possible to iterate ALL pixels like this, not just some selected points?
Another possibility would be the ImagePixelReadAccessor, which seems to be what
I need, but I don't know how to use it.
According to the class reference
(http://docs.mitk.org/2012.12/classmitk_1_1ImagePixelReadAccessor.html), there
should be a method GetPixelByWorldCoordinates, but it doesn't seem to recognize
it, as it says "identifier not found". I tried it as follows, just to test it
out:
template < typename TPixel, unsigned int VImageDimension >
void MITKPluginTest2::ItkImageProcessing( itk::Image< TPixel, VImageDimension
>* itkImage )
{
float coords[3]={100,100,100};
mitk::Point3D position(coords);
TPixel p=mitk::ImagePixelReadAccessor<float,
3>::GetPixelByWorldCoordinates(position);
}
This results in 32 errors, all looking like this, with different data types
instead of int and VImageDimension 2 or 3:
6>..\..\..\..\myProjectTwo\Plugins\org.company.myplugin2\src\internal\MITKPluginTest2.cpp(160)
: error C2027: use of undefined type
'mitk::ImagePixelReadAccessor<TPixel,VDimension>'
6> with
6> [
6> TPixel=float,
6> VDimension=3
6> ]
6>
..\..\..\..\myProjectTwo\Plugins\org.company.myplugin2\src\internal\MITKPluginTest2.cpp(148)
: see reference to function template instantiation 'void
MITKPluginTest2::ItkImageProcessing<int,2>(itk::Image<TPixel,VImageDimension>
*)' being compiled
6> with
6> [
6>
TPixel=int,
6> VImageDimension=2
6> ]
6>..\..\..\..\myProjectTwo\Plugins\org.company.myplugin2\src\internal\MITKPluginTest2.cpp(160)
: error C3861: 'GetPixelByWorldCoordinates': identifier not found
Can someone help me, please?
Best Regards,
Martin------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users