[Insight-users] I can't show Pixel Value! Did i make a mistake
using iterators
Pingkun Yan
pingkun.yan at gmail.com
Thu Feb 9 09:26:36 EST 2006
Hi charfeddine,
I am not sure if the problem is caused by
m_thresholdregionsize[2]=0;
Maybe you should set it to 1.
In fact, you have a better choice. You can use the ITK extract slice
filter, which will extract one slice from a volume. You can find
examples in ITK. Then you just need to use a 2D image iterator to read
this 2D slice, which will be much easier.
HTH,
Pingkun
On 2/9/06, charfeddine amir <charfeddine_amir at yahoo.fr> wrote:
> Hi all
> I'm reading Dicom file containing many slice, from which i extract one
> slice.
> when i try to show the contenent of the image extracted (pixel value) using
> iterators i get a black screen, and when i try GetPixel method( which is too
> slow), i can show the value.
> did i make a mistake somewhere!
>
> this is the code
>
> /************************************************************************************/
> typedef itk::Image<float,3> InputImageType;
> typedef itk::Image< float, 2 > DiasstolImageType;
>
> typedef itk::ImageRegionConstIterator< InputImageType > ConstIteratorType;
> typedef itk::ImageRegionIterator< DiasstolImageType> IteratorType;
>
> .....
> m_thresholdregion=m_OutputImage->GetLargestPossibleRegion();
> ThresholdedImageType::SizeType m_thresholdregionsize=
> m_thresholdregion.GetSize();
> m_thresholdregionsize[2]=0;
>
> ThresholdedImageType::IndexType m_thresholdregionstart =
> m_thresholdregion.GetIndex();
> m_thresholdregionstart[2]=slicenumber;
>
> m_thresholddesiredregion.SetSize( m_thresholdregionsize );
> m_thresholddesiredregion.SetIndex( m_thresholdregionstart
> );
>
>
> std::cout<<std::endl<<"---------------------------------->incidence
> N°"<<card<<std::endl;
>
>
> ConstIteratorType in( m_OutputImage, m_thresholddesiredregion );
> IteratorType out( m_DiasstoledImage, m_diasstoledimageregion );
> for ( in.GoToBegin(), out.GoToBegin(); !in.IsAtEnd(); ++in, ++out)
> {
> out.Set( in.Get() );
> std::cout<<in.Get()<<" - ";
> }
>
> /*******************************************************************************/
> i get this screen on execution:
>
> La diasstole de l'incidence courante est l'image 0
>
> ---------------------------------->incidence N°0
>
> **********************************Incidence
> suivante****************************
>
> La diasstole de l'incidence courante est l'image 0
>
> ---------------------------------->incidence N°1
>
> **********************************Incidence
> suivante****************************
>
> /*******************************************************************************************/
> But if remplace the use of iterators loop with this classic one :
>
> pixelIndex[2]=slicenumber;
> for(j=0; j<m_inputimagesize[1]; j++)
> {
> pixelIndex[1]=j;
> m_diasstoledimageindex[1]=j;
> for(i=0; i<m_inputimagesize[0]; i++)
> {
> m_diasstoledimageindex[0]=i;
> pixelIndex[0]=i;
> pixelValue = m_OutputImage->GetPixel( pixelIndex );
>
> m_DiasstoledImage->SetPixel(m_diasstoledimageindex,pixelValue);
> std::cout<<pixelValue<<" - ";
> }
> }
>
> I get the next screen:
>
> La diasstole de l'incidence courante est l'image 0
> 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 -
> 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 -
> 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 -
> 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 -
> 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 -
> 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255
> - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 -
> 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255
> - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 -
> 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255
> - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 - 255 -
> 255 - 255 - 255 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0
> - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0
> - 0 -.........
>
> any comment is welcome
> thx
> amir
>
>
> ________________________________
> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs
> exceptionnels pour appeler la France et l'international. Téléchargez la
> version beta.
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
More information about the Insight-users
mailing list