[vtkusers] vtkImageMedian3D with Custom Source

Georg Ziegler gziegler at mail.tuwien.ac.at
Wed Feb 3 05:52:47 EST 2010


Am 02.02.2010 22:27, schrieb David Doria:
> On Tue, Feb 2, 2010 at 2:09 PM, Georg Ziegler
> <gziegler at mail.tuwien.ac.at <mailto:gziegler at mail.tuwien.ac.at>> wrote:
>
>     Hello!
>
>     I am not very experienced with the workings of the new pipeline but
>     I have managed to write a custom source similar to the one in this
>     example:
>     http://www.vtk.org/Wiki/VTK_Examples_vtkImageAlgorithm_Source
>
>     Then I have built a pipeline like so:
>
>     vtkImageMedian3D->SetInputConnection(vtkMyCustomSource->GetOutputPort());
>     vtkVolumeRayCastMapper->SetInputConnection(vtkImageMedian3D->GetOutputPort());
>
>     Unfortunately, this setup does not produce a volume as expected.
>     If I connect my custom source directly to the mapper I do get a result.
>     vtkVolumeRayCastMapper->SetInputConnection(vtkMyCustomSource->GetOutputPort());
>
>     Can you point me to where the problem might be?
>     Do I have to implement another method in my custom source besides
>     RequestData()?
>
>     Regards,
>     Georg
>
>
> Maybe you're having the same issue I was having a few days ago:
> Bill found that the solution was to add these lines at the end of
> RequestData():
>
>    output->ShallowCopy(image);
>    output->SetExtent(image->GetExtent());
>    output->SetUpdateExtent(image->GetUpdateExtent());
>    output->SetWholeExtent(image->GetWholeExtent());
>
> I just added them to the example page that you were referring to.
>
> I'm not exactly sure why it is necessary, but it seemed to fix my issue.
>
> Let me know if it works for you.
>
> Thanks,
>
> David
>

Hello David!

Thank you for your helpful reply. That was one half of the solution.
The other half was me being sloppy when creating the image in RequestData().

After playing around I found that I had to manually set the following:
this->image->SetExtent(0, sizeX-1, 0, sizeY-1, 0, sizeZ-1);
this->image->SetWholeExtent(0, sizeX-1, 0, sizeY-1, 0, sizeZ-1);
this->image->SetUpdateExtentToWholeExtent();
this->image->RequestExactExtentOff();

As I'm using images with scalar data of type unsigned char I also need 
to set
this->image->SetScalarTypeToUnsignedChar();

I guess if you are using some other type you have to use one of the 
other SetScalarTypeToXXXXX() methods.

This seems to fix the problem.

Maybe it would be good to mention in the example that you need to 
manually set these things when creating a vtkImageData object from scratch.

Regards,
Georg



More information about the vtkusers mailing list