Hello,<br>I'm trying to view an image from 3D raw volume. I'm using vtkImageReslice for doing it. But, I got a blank view after viewing the output using vtkImageViewer. Here is my code :<br><br>------------------------------------------------------------------------------------------------<br>
vtkImageReader2 *reader = vtkImageReader2::New();<br> reader->SetFileName("prone8.raw");<br> reader->SetFileDimensionality(3);<br> reader->SetDataByteOrderToBigEndian();<br> reader->SetNumberOfScalarComponents(1);<br>
reader->SetDataExtent(0, 511, 0, 511, 0, 462);<br> reader->SetDataSpacing(0.625, 0.625, 1.0);<br> reader->SetDataOrigin(0.0, 0.0, 0.0);<br> reader->UpdateWholeExtent();<br> //calculate the center of the volume<br>
reader->GetOutput()->UpdateInformation();<br> int extent[6];<br> double spacing[3];<br> double origin[3];<br> reader->GetOutput()->GetWholeExtent(extent);<br> reader->GetOutput()->GetSpacing(spacing);<br>
reader->GetOutput()->GetOrigin(origin);<br> double center[3];<br> center[0] = (origin[0] + spacing[0] * 0.5 * (extent[0] + extent[1]));<br> center[1] = (origin[1] + spacing[1] * 0.5 * (extent[2] + extent[3]));<br>
center[2] = (origin[2] + spacing[2] * 0.5 * (extent[4] + extent[5]));<br> //matrix for axial view<br> static double axialElements[16] = {<br>        1, 0, 0, 0,<br>        0, 1, 0, 0,<br>        0, 0, 1, 0,<br>        0, 0, 0, 1};<br> //set slice orientation<br>
vtkMatrix4x4 *resliceAxes = vtkMatrix4x4::New();<br> resliceAxes->DeepCopy(axialElements);<br> <br>//set the point through which to slice<br> //set i,j setElement(i,j,double);<br>resliceAxes->SetElement(0, 3, center[0]);<br>
resliceAxes->SetElement(1, 3, center[1]);<br> resliceAxes->SetElement(2, 3, center[2]);<br> <br>//extract slice<br> vtkImageReslice *reslice = vtkImageReslice::New();<br> reslice->SetInputConnection(reader->GetOutputPort());<br>
reslice->SetOutputDimensionality(2);<br> reslice->SetResliceAxes(resliceAxes);<br> reslice->SetInterpolationModeToLinear();<br> <br>// Create a greyscale lookup table<br> vtkLookupTable *table = vtkLookupTable::New();<br>
table->SetRange(0, 2000); // image intensity range<br> table->SetValueRange(0.0, 1.0); // from black to white<br> table->SetSaturationRange(0.0, 0.0); // no color saturation<br> table->SetRampToLinear();<br>
table->Build();<br><br> // Map the image through the lookup table<br> vtkImageMapToColors *color = vtkImageMapToColors::New();<br> color->SetLookupTable(table);<br> color->SetInputConnection(reslice->GetOutputPort());<br>
/ <br> //view the image<br> viewer = vtkImageViewer2::New();<br> viewer->SetInput(color->GetOutput());<br> viewer->SetSize(512,512);<br>// viewer->SetZSlice(sliderValueChanged());<br> qvtk->SetRenderWindow(viewer->GetRenderWindow()); <br>
reader->Delete(); <br>------------------------------------------------------------------------------------------------<br><br>I'm using qt3 here. Plese help me....<br>Thanks...<br><br><br><br><br><br><br>