[Insight-developers] RawImageIO does not byte swap properly

Will Schroeder will.schroeder@kitware.com
Fri, 19 Apr 2002 13:17:31 -0400


Hi Lydia-

You are doing this on a Windows platform, yes?

Will

At 05:33 PM 4/17/2002 -0700, Lydia Ng wrote:
>Has anyone had success with RawImageIO for reading in
>unsigned short (16bit) data?
>
>I believe the byte swapping logic in RawImageIO::Read() is wrong.
>
>Attached is small test 5x5 "unsigned short" test image which is
>1 2 3 4 5
>6 7 8 9 10
>11 12 13 14 15
>16 17 18 19 20
>The image is binary and big endian.
>
>Also attached is my code for reading it in and writing it to screen.
>The output I get is
>256 512 768 1024 1280
>1536 1792 2048 2304 2560
>2816 3072 3328 3584 3840
>4096 4352 4608 4864 5120
>5376 5632 5888 6144 6400
>which is definitely a byte swapping problem.
>
>----------------------------------------------
>Secondly the line 205 is also problematic:
>ByteSwapper<PixelType>::SwapRangeBE((PixelType *)buffer,
>m_Strides[VImageDimension+1]);
>
>For my test case:
>m_Strides =3D { 2, 2, 10, 50 }
>
>ByteSwapper<PixelType>::SwapRangeBE( buffer, N) is suppose
>to swap N number of PixelType  which in my case
>should 5 * 5 =3D 25
>
>Also, I don't think ByteSwapper with respect to PixelType is going deal
>multiple component data properly.
>----------------------------------------------
>
>Can someone have a look at this for me? Thanks.
>
>Hoping to get validation completed before d-day .......
>Lydia
>
>
>=9E=C8 =86=D7^=BD=E9h=A5=EA=EC=99=A8=A5=8Ax%=8A=CBH=9E=C8=20
>=86=D7^=BD=E9h=A5=EA=EC=A6=E6=E5=89=C9"=B7=ABy=CA&=86=DBi=FF=FAnnX=9C=92+pj=
=B7=9C=A2o=E6j)fj=7F=E5=8A=CBb=9D=FA?=8A{"=82]z=F7=A5=A2=97=AB