[Insight-users] rounding an index pointer

David Doria daviddoria at gmail.com
Sun Jun 12 12:36:33 EDT 2011


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


More information about the Insight-users mailing list