[Insight-users] I can't show Pixel Value! Did i make a mistake using iterators

charfeddine amir charfeddine_amir at yahoo.fr
Thu Feb 9 05:03:23 EST 2006


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060209/bfcccf20/attachment-0001.html


More information about the Insight-users mailing list