[Insight-users] rounding an index pointer

john smith mkitkinsightuser at gmail.com
Sun Jun 12 13:00:18 EDT 2011


I have used int and unsigned char. But when I took the value of a pixel of
the un-rescaled image, it was 204. When I solved the rescale equation by
hand  for value 204 and for rescale values [0,255], I get the value 113,58.
So I should have taken the value 114.Instead of this when I get the value of
the rescaled image then I get the value 113.Why is this happening?

2011/6/12 john smith <mkitkinsightuser at gmail.com>

> 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/358c3b9e/attachment.htm>


More information about the Insight-users mailing list