[vtkusers] Try Again - vtkImageActor shearing distortion
Dean Inglis
dean.inglis at camris.ca
Thu Dec 4 13:36:30 EST 2003
Hi,
my original post has gone unanswered:
http://public.kitware.com/pipermail/vtkusers/2003-November/021035.html
so in the interim, I have done some more tests.
I constructed the following pipeline to read in a raw 2D
image of signed short data with a header offset and pass the
data through a filter to a vtkImageActor in two separate
renderers/windows:
<intitalize>
m_reader = vtkImageReader::New();
m_reader->SetDataScalarTypeToShort();
m_reader->SetDataByteOrderToLittleEndian();
m_reader->SetFileDimensionality(2);
m_reader->FileLowerLeftOff();
m_reader->SetDataOrigin(0,0,0);
m_reader->SetHeaderSize(1609);
m_reader->SetDataSpacing (0.2, 0.2, 1.0);
m_reader->ReleaseDataFlagOff();
m_inputImageActor = vtkImageActor::New();
m_outputImageActor = vtkImageActor::New();
<snip>
<read the data, toggle between tow files with the same extent>
String fname;
if(i1ori2)
{
fname = "I0021251.m01";
}
else
{
fname = "I0021251.m02";
}
i1ori2 = !i1ori2;
struct stat statbuf;
FILE *stream;
if ((stream = fopen(fname.c_str(), "rb"))
== NULL)
{
return;
}
fstat(fileno(stream), &statbuf);
fclose(stream);
int extent = static_cast<int>(sqrt((statbuf.st_size - 1609)/2))-1;
m_reader->SetFileName(fname.c_str());
m_reader->SetDataExtent(0,extent,0,extent,0,0);
m_reader->Update();
<snip>
<setup pipeline 1>
vtkImageMapToWindowLevelColors* m_WLMap =
vtkImageMapToWindowLevelColors::New();
m_WLMap->ReleaseDataFlagOn();
m_WLMap->SetInput(m_reader->GetOutput());
m_WLMap->SetWindow(255);
m_WLMap->SetLevel(127.5);
m_WLMap->Update();
m_inputImageActor->SetInput(m_WLMap->GetOutput());
m_inputImageActor->VisibilityOn();
m_inputImageActor->SetDisplayExtent(
m_inputImageActor->GetInput()->GetWholeExtent());
m_inputImageActor->Modified();
vtkWindow1->Repaint(); // a Borland vtk renderer, render window and
interactor all in one
m_WLMap->Delete();
<snip>
<setup pipeline 2>
vtkImageMapToWindowLevelColors* m_WLMap2 =
vtkImageMapToWindowLevelColors::New();
m_WLMap2->ReleaseDataFlagOn();
m_WLMap2->SetInput(m_reader->GetOutput());
m_WLMap2->SetWindow(255);
m_WLMap2->SetLevel(127.5);
m_WLMap2->Update();
m_outputImageActor->SetInput(m_WLMap2->GetOutput());
m_outputImageActor->VisibilityOn();
m_outputImageActor->SetDisplayExtent(
m_outputImageActor->GetInput()->GetWholeExtent());
m_outputImageActor->Modified();
vtkWindow2->Repaint(); // a Borland vtk renderer, render window and
interactor all in one
m_WLMap2->Delete();
<snip>
Ok so far these pipelines execute properly and toggling between different
images
with the same extent is error free. If I replace one of the
vtkImageMapToWindowLevelColors filters to vtkImageShiftScale or
vtkImageClamp
in either of the pipelines, I get shearing distortion!!!!
Please help!
Dean
More information about the vtkusers
mailing list