[Insight-users] Error using iterators! I can't get Pixel Value!!
charfeddine amir
charfeddine_amir at yahoo.fr
Fri Feb 10 02:18:22 EST 2006
Hi all
Hi Yan
thx for reply
but the problem is that i need to browse each pixel of the image extracted, so i have to use iterators, and i did, and there the same problem occur.
i make a test after reading the pixel if it's value is equal to 0, if not i process it and so on,
but all the test are false, mean he find that all pixel value are equal to 0( he didn't process any pixel) even many pixel are not equal to 0. if i use the classic method ( using GetPixel() method) , the program work well, but it is very slow!
this is the part of code where i use the iterators :
......
ConstIteratorType2 out2( m_DiasstoledImage, m_diasstoledimageregion );
for ( out2.GoToBegin(); !out2.IsAtEnd(); ++out2)
{
if(out2.Get()!=0)
{
m_diasstoledimageindex=out2.GetIndex();
// Coord du pixel consid‚r‚ dans le plan image en millimetres.
CoordInRecp[0]=m_diasstoledimageindex[0]*m_diasstoledimagespacing[0];
CoordInRecp[1]=m_diasstoledimageindex[1]*m_diasstoledimagespacing[0];
.......
thx in advance
any comment is welcome
amir,
Pingkun Yan <pingkun.yan at gmail.com> a écrit : 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 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 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<<<"---------------------------------->incidence
> N°"<<
>
>
> 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<<<" - ";
> }
>
> /*******************************************************************************/
> 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
> {
> pixelIndex[1]=j;
> m_diasstoledimageindex[1]=j;
> for(i=0; i
> {
> m_diasstoledimageindex[0]=i;
> pixelIndex[0]=i;
> pixelValue = m_OutputImage->GetPixel( pixelIndex );
>
> m_DiasstoledImage->SetPixel(m_diasstoledimageindex,pixelValue);
> std::cout<
<<" - ";
> }
> }
>
> 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
>
>
>
---------------------------------
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/20060210/e29961d0/attachment.html
More information about the Insight-users
mailing list