[vtkusers] vtkImageActor return error from function

Jothy jothybasu at gmail.com
Fri Oct 1 15:43:16 EDT 2010


If I want to get a vtkImageActor from that function, should I replace void
with v

On Fri, Oct 1, 2010 at 12:33 PM, Jothy <jothybasu at gmail.com> wrote:

>
> Hi all,
>
> I am trying to get the vtkImageACtor form a function, but it says
> vtkImageActor is protected.
>
> I have tried even without vtkSmartPointer.
>
> Here is the code!
>
> Thanks
>
>  void MainWindow::imageReslice(int sliceValue)
>
> {
>
> this->imageData->GetWholeExtent(this->imgExtent);
>
> //qDebug()<<imgExtent[0]<<imgExtent[1]<<imgExtent[2]<<imgExtent[3]<<imgExtent[4]<<imgExtent[5];
>
> this->imageData->GetSpacing(this->imgSpacing);
>
> //qDebug()<<this->imgSpacing[0]<< this->imgSpacing[1]<< this->imgSpacing[2];
>
> this->imageData->GetOrigin(this->imgOrigin);
>
> //qDebug()<<this->imgOrigin[0]<< this->imgOrigin[1]<< this->imgOrigin[2];
>
> double center[3];
>
>  center[0] = this->imgOrigin[0] + this->imgSpacing[0] * 0.5 * (imgExtent[0] + imgExtent[1]);
>
>  center[1] = this->imgOrigin[1] + this->imgSpacing[1] * 0.5 * (imgExtent[2] + imgExtent[3]);
>
>  center[2] = this->imgOrigin[2] + this->imgSpacing[2] * 0.5 * (imgExtent[4] + imgExtent[5]);
>
>  // Matrices for axial, coronal, sagittal, oblique view orientations
>
>    static double axialElements[16] = {
>
>             1, 0, 0,0 ,
>
>             0, 1, 0, 0,
>
>             0, 0, 1, sliceValue,
>
>             0, 0, 0, 1 };
>
>    //static double coronalElements[16] = {
>
>    //         1, 0, 0, 0,
>
>    //         0, 0, 1, 0,
>
>    //         0,-1, 0, 0,
>
>    //         0, 0, 0, 1 };
>
> //   static double sagElements[16] = {
>
> //             0, 0,-1, 0,
>
> //            1, 0, 0, 0,
>
> //            0,-1, 0, 0,
>
> //            0, 0, 0, 1 };
>
> //   // Set the slice orientation
>
>     vtkSmartPointer<vtkMatrix4x4> resliceAxes =
>
>       vtkSmartPointer<vtkMatrix4x4>::New();
>
>     resliceAxes->DeepCopy(axialElements);
>
> //    // Set the point through which to slice
>
> //    resliceAxes->SetElement(0, 3, center[0]);
>
> //    resliceAxes->SetElement(1, 3, center[1]);
>
> //    resliceAxes->SetElement(2, 3, center[2]);
>
>     // Extract a slice in the desired orientation
>
>     vtkSmartPointer<vtkImageReslice> reslice =
>
>       vtkSmartPointer<vtkImageReslice>::New();
>
>     reslice->SetInput(this->imageData);
>
>     reslice->SetOutputDimensionality(2);
>
>     reslice->SetResliceAxes(resliceAxes);
>
>     reslice->SetInterpolationModeToLinear();
>
>     // Create a greyscale lookup table
>
>     vtkSmartPointer<vtkLookupTable> table =
>
>       vtkSmartPointer<vtkLookupTable>::New();
>
>     table->SetRange(-300,900); // image intensity range
>
>     table->SetValueRange(0.0, 1.0); // from black to white
>
>     table->SetSaturationRange(0.0, 0.0); // no color saturation
>
>     table->SetRampToLinear();
>
>     table->Build();
>
>     // Map the image through the lookup table
>
>     vtkSmartPointer<vtkImageMapToColors> color =
>
>       vtkSmartPointer<vtkImageMapToColors>::New();
>
>     color->SetLookupTable(table);
>
>     color->SetInputConnection(reslice->GetOutputPort());
>
>       // Return the image
>
>    vtkSmartPointer<vtkImageActor>   imgActor =  vtkSmartPointer<vtkImageActor>::New();
>
>     imgActor->SetInput(color->GetOutput());
>
>    return imgActor;
>
> }
>
>
> Jothy
>
> --
> Research Scholar
> Dept. of Medical Physics
> Clatterbridge Centre for Oncology
> UK
>
>


-- 
Research Scholar
Dept. of Medical Physics
Clatterbridge Centre for Oncology
UK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101001/ff478d82/attachment.htm>


More information about the vtkusers mailing list