[vtkusers] ImageReader Mystery

John Vard jvard at tcd.ie
Mon Oct 20 09:06:40 EDT 2003


Thanks for that Dean,

Gave your code suggestion a go.. Apologies for the error in the DataExtent 
property.. However problem still remains.. In fact the problem has gotten 
even more intricate...

I've noticed the following:
1. Files which don't open are pre-rotated. Yet I don't understand why this 
should effect the rendering process??

2. By altering my display configurations and loading the "dri" module, all raw 
files are rendered as a white canvas. Has anybody ever come across this 
problem??     


On Sunday 19 October 2003 20:54, dean.inglis at camris.ca wrote:
> John,
>
> looking at your python code, there may be a couple of
> small but important details to consider:
>
> *********************************************************
> reader = vtkImageReader2()
> reader.SetFileName("<file.raw>")
> reader.SetDataScalarTypeToUnsignedShort()
> reader.SetDataByteOrderToLittleEndian()
> reader.SetDataSpacing(<Pix_SpacingX>,<Pix_SpacingY>,1.0)
> reader.SetDataExtent(0,<Column>,0,<Row>,0,0)
> *********************************************************
>
> The data extent is usually of the form:
>
> 0,NColumn-1,0,NRow-1,0,NSlice-1
>
> so is your above code correct?
>
> The Shiftscale filter may need to be corrected:
>
> ********************************************************
> # Determine image scalar range
> scalarmin,scalarmax = data.GetScalarRange()
> print scalarmin,scalarmax
> scale = 255/(scalarmax-scalarmin)
>
> shiftScale = vtkImageShiftScale()
> shiftScale.SetInput(reader.GetOutput())
> shiftScale.SetShift(0)
> shiftScale.SetScale(scale)
> shiftScale.SetOutputScalarTypeToUnsignedChar()
> *******************************************************
>
> This is ok as long as scalarmin is 0.  For
> best results do the following:
>
> intercept = -scale*scalarmin
> trueshift = intercept/scale
> shiftScale.SetOutputScalarTypeToUnsignedChar()
> shiftScale.SetShift(trueshift)
> shiftScale.SetScale(scale)
> shiftScale.SetInput(reader.GetOutput())
>
>
> Dean
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq> Follow this link to
> subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-- 
Regards
John Vard

Trinity Centre for Bioengineering
Mechanical Engineering Dept.
Trinity College
Dublin 2
Ireland

e-mail: jvard at tcd.ie
www.biomechanics.ie
---------------------------------------------------------------------------------------------------
Hello Users

I'm having difficulty displaying a .raw image within the 3D render window. I'm 
currently using the vtkImageCast Class to alter the scalar type to unsigned 
character which is required by vtkImageActor. However the resulting render is 
not as expected. It appears that the change in scalar type is altering the 
pixel colouring, perhaps... How can I correct this and 3D render the image 
correctly?? Thanks for your time   

--
John V.




More information about the vtkusers mailing list