[vtkusers] Problem with SimpleImageToImageFilter Implementation

Christian Werner christian.werner at rwth-aachen.de
Thu Feb 11 14:34:30 EST 2010


Thank you for the quick response. I am afraid that won't help, since I 
am not implementing a viewer myself. My Filter is a plugin for Paraview, 
I don't do anything about any painter. So maybe that's a Paraview issue?

btw. What are these "Scalars"? Format data? Is there some setup I could 
change in my vtkImageData output to fix that?


David Doria wrote:
> On Thu, Feb 11, 2010 at 11:33 AM, Christian Werner 
> <christian.werner at rwth-aachen.de 
> <mailto:christian.werner at rwth-aachen.de>> wrote:
>
>     Hello!
>
>     I used the vtkSimpleImageToImageFilter to make a nifty little
>     segmentation to get started. Below is how I overwrote the
>     SimpleExecute function. It looks good and actually does the job,
>     at least in a Reader>MyFilter>Writer setup. But if its passed to a
>     vtkTexturePainter I get a warning that comes from the function
>
>     int vtkTexturePainter::SetupScalars(vtkImageData* input) ...
>
>     Warning: In /opt/ParaView3/Servers/Filters/vtkTexturePainter.cxx,
>     line 173
>     vtkTexturePainter (0x1a34fd0): Failed to locate selected scalars.
>     Will use image scalars by default.
>
>
>     What is displayed then (this is all with Paraview by the way) is
>     an image which is indeed segmented as meant, but it has strange
>     colors. The background color of the image mysteriously gets the
>     background color of the 2d viewer (but should be 0/black), and the
>     foreground color (which should be white) is some ugly pink, or
>     green, now that I tried again. Also Paraview does not seem to have
>     information about the data array, at least its not listed where as
>     there IS information on the original image: DataType: unsigned
>     char, Data Ranges[0,255]...
>
>
>     Here is my code:
>
>
>     void vtkDislev::SimpleExecute(vtkImageData* input, vtkImageData*
>     output)
>     {
>       if (input==NULL) {
>       vtkErrorMacro(<<"Bad Input to vtkDislev");
>       return;
>       }
>         int dim[3];
>       input->GetDimensions(dim);
>       int numvox  = dim[0]*dim[1]*dim[2];
>       int numcomp = input->GetNumberOfScalarComponents();
>         vtkDataArray* inarray  = input->GetPointData()->GetScalars();
>       vtkDataArray* outarray = output->GetPointData()->GetScalars();
>         unsigned char in=255;
>       unsigned char out=0;
>       for (int component=0; component < numcomp; component++) {
>       for (int i=0; i < numvox; i++) {
>           unsigned char v=inarray->GetComponent(i,component);
>           if (v >= this->LowerThreshold && v<=this->UpperThreshold) {
>           outarray->SetComponent(i,component,in);
>           } else {
>           outarray->SetComponent(i,component,out);             }
>       }
>       }
>     }
>
>
>     Anyone any idea?
>
>     Best regards,
>     Christian
>     __
>
>
> It looks like this (from vtkTexturePainter.cxx) is returning NULL:
>
>   vtkDataArray* scalars = vtkAbstractMapper::GetScalars(input,
>     this->ScalarMode, 
>     this->ScalarArrayName? VTK_GET_ARRAY_BY_NAME : VTK_GET_ARRAY_BY_ID,
>     this->ScalarArrayIndex,
>     this->ScalarArrayName,
>     cellFlag);
>
> It looks like you can call
> painter->SetScalarArrayName("yourArray");
>
> to set the array that you want it to use.
>
> Hope that helps,
>
> David
> ------------------------------------------------------------------------
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   




More information about the vtkusers mailing list