[vtkusers] problem with blending

amit saxena amits at wiproge.med.ge.com
Mon Jan 15 19:06:44 EST 2001


Hi,
   I am trying to register two 3D data sets dataset1 and dataset2. After
registering I 
       1) transform dataset2 using vtkImageReslice
       2) blend the images using vtkImageBlend
       3) display the data using imageViewer.
       4) display the 3D data of the blended image.
 
   Now after scaling the size of dataset1 and transformed dataset2 is
not same. Hence when I blend the images, the images donot overlap.
Instead the dataset2 starts from the lower left corner in the window.
Using vtkReslice I tried to tried to bring the images in place, but this
time I get the original image instead of the transformed one.Further a
3D view of the images is much worse. Can somebody please help me out.
The pipeline is as follows :
 
void Reader::display() {

vtkTransform *transO1 = vtkTransform::New();

transO1->Translate(15,-5,0);

vtkTransform *transO2 = vtkTransform::New();

transO2->Translate(width/2,height/2,0);

vtkTransform *trans1 = vtkTransform::New();

trans1->Scale(0.9,0.9,1);

trans1->Translate(0,10,2); 

vtkTransform *trans = vtkTransform::New();

trans->Concatenate(transform);

vtkVolume16Reader *reader1 = vtkVolume16Reader::New();

reader1->SetFilePrefix(fileName1[0]);

reader1->SetHeaderSize(header[0]);

if (byteSwap) 

reader1->SwapBytesOn();

reader1->SetImageRange(range[0][0],range[0][1]);

reader1->SetDataSpacing(space[0][0], space[0][1], space[0][2]);

reader1->SetDataDimensions(height, width);

vtkImageReslice *reslice1 = vtkImageReslice::New();

reslice1->SetInput(reader1->GetOutput());

reslice1->InterpolateOn();

reslice1->SetInterpolationModeToCubic();

reslice1->OutputAlwaysCenteredOnInputOn() ;

vtkImageViewer *viewer1 = vtkImageViewer::New();

viewer1->SetInput(reslice1->GetOutput());

viewer1->SetColorLevel(1000);

viewer1->SetZSlice(0);

viewer1->Render();

reader1->Delete();

char a;

cin>>a;

vtkVolume16Reader *reader2 = vtkVolume16Reader::New();

reader2->SetFilePrefix(fileName1[1]);

reader2->SetHeaderSize(header[1]);

if (byteSwap) 

reader2->SwapBytesOn();

reader2->SetImageRange(range[1][0],range[1][1]);

reader2->SetDataSpacing(space[1][0], space[1][1], space[1][2]);

reader2->SetDataDimensions(height, width);

reslice->SetInput(reader2->GetOutput());

reader2->Delete();

reslice->SetOutputSpacing(1,1,1);

reslice->InterpolateOn();

reslice->SetInterpolationModeToCubic();

reslice->OutputAlwaysCenteredOnInputOn() ;

reslice->SetResliceTransform(trans);

vtkImageTranslateExtent *extTrans = vtkImageTranslateExtent::New();

extTrans->SetInput(reslice->GetOutput());

extTrans->SetTranslation(width*0.0,height*0.0,0);

vtkImageReslice *reslice2 = vtkImageReslice::New();

reslice2->SetInput(extTrans->GetOutput());

vtkImageViewer *viewer2 = vtkImageViewer::New();

viewer2->SetInput(reslice->GetOutput());

viewer2->SetColorLevel(1000);

viewer2->SetZSlice(0);

viewer2->Render();

cin>>a;

vtkImageBlend *blend = vtkImageBlend::New();

blend->SetInput(0,reslice1->GetOutput());

blend->SetInput(1,reslice->GetOutput());

blend->SetOpacity(1,0.5);

vtkImageViewer *viewerB = vtkImageViewer::New();

viewerB->SetInput(blend->GetOutput());

viewerB->SetColorWindow(255.0);

viewerB->SetColorLevel(127.5);

viewerB->Render();

cin>>a;

vtkRenderWindow *win = vtkRenderWindow::New();

vtkRenderer *ren = vtkRenderer::New();

win->AddRenderer(ren);

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

iren->SetRenderWindow(win);

vtkImageToStructuredPoints *iToStruct =
vtkImageToStructuredPoints::New();

iToStruct->SetInput(blend->GetOutput());

vtkMarchingCubes *march = vtkMarchingCubes::New();

march->SetInput(iToStruct->GetOutput());

march->ComputeScalarsOff();

march->ComputeGradientsOff();

march->ComputeNormalsOff();

march->SetValue(0,150);

vtkSmoothPolyDataFilter *smoother = vtkSmoothPolyDataFilter::New();

smoother->SetInput(march->GetOutput());

smoother->SetNumberOfIterations(6);

smoother->SetRelaxationFactor(0.1);

smoother->SetFeatureAngle(10);

smoother->FeatureEdgeSmoothingOff();

smoother->BoundarySmoothingOff();

smoother->SetConvergence(0);

vtkPolyDataNormals *normals = vtkPolyDataNormals::New();

normals->SetInput(smoother->GetOutput());

normals->SetFeatureAngle(10);

vtkStripper *stripper = vtkStripper::New();

stripper->SetInput(normals->GetOutput());

vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();

mapper->SetInput(stripper->GetOutput());

vtkActor *actor = vtkActor::New();

actor->SetMapper(mapper);

ren->AddActor(actor);

win->Render();

iren->Start();

}

 
 
AMIT 
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20010115/79eb7e3f/attachment.htm>


More information about the vtkusers mailing list