[vtkusers] Image Data to Polydata
cspl
affable at hd2.dot.net.in
Tue Oct 29 09:00:02 EST 2002
Dear friends,
i want to display the grayscale images(medical images) and fit to image
in given size.But the following code is giving color image as output but i want grayscale image as output.And how to convert image data to
polydata.Please give me suggestion.
For that output i wrote the folowing code:
vtkImageReader *Reader = vtkImageReader::New();
Reader->SetDataByteOrderToLittleEndian();
Reader->SetDataExtent(0,511,0,511,1,1);
Reader->SetFileName(filepath);//give here filepath
Reader->SetDataSpacing(1.0, 1.0, 1.0);
Reader->SetDataMask(0x7fff);
Reader->SetDataScalarTypeToUnsignedShort();
////////////////
//vtkImageLuminance *luminance=vtkImageLuminance::New();
//luminance->SetInput(Reader->GetOutput());
vtkImageDataGeometryFilter *geometry=vtkImageDataGeometryFilter::New();
geometry->SetInput(Reader->GetOutput());
vtkWarpScalar *warp=vtkWarpScalar::New();
warp->SetInput(geometry->GetOutput());
warp->SetScaleFactor(-0.1);
vtkMergeFilter *merge=vtkMergeFilter::New();
merge->SetGeometry(warp->GetOutput());
merge->SetScalars(Reader->GetOutput());
vtkDataSetMapper *mapper=vtkDataSetMapper::New();
mapper->SetInput(merge->GetOutput());
mapper->SetScalarRange(0, 255);
mapper->ImmediateModeRenderingOff();
vtkActor *actor=vtkActor::New();
actor->SetMapper(mapper);
vtkRenderer *ren1=vtkRenderer::New();
vtkRenderWindow *renWin=vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
// iren->SetRenderWindow(renWin);
ren1->AddActor(actor);
renWin->SetSize(250,250); //threse size are given dynamically
renWin->SetParentId(m_wnd);//control Id.
renWin->Render();
Thanking you,
Regards,
satyanarayana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20021029/33b77d9f/attachment.htm>
More information about the vtkusers
mailing list