[vtkusers] vtkImageReader

#YAN RI AN# PS7278514B at ntu.edu.sg
Sun Aug 25 08:09:52 EDT 2002


Dear all:
I use the window NT based computer & VC6.0 compiler.
 I also meet the problem in Visualizeing Image & Volume Rendering:
The source code below:
#include "vtkImageViewer.h"
#include "vtkImageReader.h"
#include "vtkImageMagnify.h"
#include "vtkImageShrink3D.h"
#include "vtkImageGradient.h"
#include "vtkImageDataStreamer.h"

int main(int argc, char *argv[])
{
  int i,j;
  vtkImageReader *reader=vtkImageReader::New();
  reader->SetFilePrefix("c:/Vtkdata/Data/headsq/quarter");//from manual
  reader->SetDataByteOrderToLittleEndian();
  reader->SetDataExtent(0,255, 0,255, 1,93);
  reader->SetDataMask(0x7ff);

  vtkImageMagnify *mag=vtkImageMagnify::New();
  mag->SetInput(reader->GetOutput());
  mag->SetMagnificationFactors (3,3,1);

  vtkImageGradient *grad=vtkImageGradient::New();
  grad->SetInput(mag->GetOutput());
  grad->SetDimensionality(3);

  vtkImageShrink3D *shrink=vtkImageShrink3D::New();
  shrink->SetInput(grad->GetOutput());
  shrink->SetShrinkFactors(3,3,1);

  vtkImageDataStreamer *ids=vtkImageDataStreamer::New();
  ids->SetInput(shrink->GetOutput());
  ids->SetNumberOfStreamDivisions(20) ;
  ids->UpdateWholeExtent();

  vtkImageViewer *viewer=vtkImageViewer::New();
  viewer->SetInput(ids->GetOutput());
  viewer->SetColorLevel(0);
  viewer->SetColorWindow(200);

  //interact with data
  for (j=0;j<10;j++)
  {
	  for (i=0;i<93;i++)
	  {
		  viewer->SetZSlice(i);
		  viewer->Render();
	  }
  }
  // clean up
  viewer->Delete();
  reader->Delete();
  grad->Delete();
  shrink->Delete();
  mag->Delete();

  return 0;
}
when I execute the program,it happened warnning.
I change the reader->SetDataExtent(0,255, 0,255, 1,93);
To reader->SetDataExtent(0,63, 0,63, 1,93); the warning solved.
Question1: The (Xmin, Xmax,Ymin,Ymax,Zmin,Zmax) means Millimeter?
Question2:The Maxmum Value can not extend(the User'sGuide says can)?

How the upper program bind with:
 	vtkRenderer* ren=vtkRenderer::New();
    ren-> SetBackground (1,1,1);

	vtkRenderWindow* renWin=vtkRenderWindow::New();
    renWin-> AddRenderer(ren);
    renWin-> SetSize(500,500);

	vtkRenderWindowInteractor* iren=vtkRenderWindowInteractor::New();
iren-> SetRenderWindow(renWin);
so the renderering can permanently show.
		thanks very much.
		my e-mail address is :
		ps7278514b at ntu.edu.sg <mailto:ps7278514b at ntu.edu.sg>

*************************************** 
* Best Regards
* Yan Rian (Research Student) 
* Email : ps7278514b at ntu.edu.sg
* Lab : AMRC Research Centre 
* Nanyang Technological University 
* Singapore 
***************************************





More information about the vtkusers mailing list