[Insight-users] rounding an index pointer

john smith mkitkinsightuser at gmail.com
Sun Jun 12 12:39:08 EDT 2011


Thanks for your response.
If I use int or unsigned char, then 113.581 would be 114 and 113.281 would
be 113. Is this correct?


2011/6/12 David Doria <daviddoria at gmail.com>

> On Sun, Jun 12, 2011 at 12:32 PM, john smith <mkitkinsightuser at gmail.com>
> wrote:
> > Hi to all,
> >
> > I am using a reader to read an image and then pass the reader to a
> > RescaleIntensityImageFilter, with which I rescale the image from 0 to
> > 255.Then I am using an index type pointer tto get the pixel value, as it
> > seems bellow:
> >
> >  InputImageType::Pointer image = filter_rescale->GetOutput();
> >              InputImageType::IndexType index =
> > filter_rescale->GetOutput()->GetLargestPossibleRegion().GetIndex();
> >
> >                            InputImageType::IndexType currentIndex;
> >                            currentIndex[0] = k2;
> >                            currentIndex[1] = k1;
> >                            currentIndex[2] =
> > ui->verticalScrollBar_z->value();
> >                            InputImageType::PixelType currentValue =
> > image->GetPixel(currentIndex);
> >
> > But when I get the values of currentIndex, I get for example a value
> > 113.581. I want to know in this case which rounding would be correct, the
> > 113 value or the 114 value.And how I could achieve this rounding?
> >
> > Thanks in advance
>
>
> You could set the OutputImageType of the RescaleImageFilter to
> unsigned char or int or something and it would cast it for you, so you
> wouldn't have to deal with rounding. And what do you mean the
> "correct" rounding? According to any rounding I know, 113.581 would be
> rounded to 114.
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110612/f515d4da/attachment.htm>


More information about the Insight-users mailing list