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


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to