[vtkusers] Why is the image red?

David Doria daviddoria+vtk at gmail.com
Mon Dec 14 17:45:03 EST 2009


On Mon, Dec 14, 2009 at 4:58 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> vtkTexture.h
>  // Description:
>  // Turn on/off the mapping of color scalars through the lookup table.
>  // The default is Off. If Off, unsigned char scalars will be used
>  // directly as texture. If On, scalars will be mapped through the
>  // lookup table to generate 4-component unsigned char scalars.
>  // This ivar does not affect other scalars like unsigned short, float,
>  // etc. These scalars are always mapped through lookup tables.
>
> On Mon, Dec 14, 2009 at 4:09 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
>> On Mon, Dec 14, 2009 at 3:58 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>> The class vtkImageMapToColors can apply a lookup table to a whole
>>> image.  As for vtkTexture, it has a set of rules that control when it
>>> applies a lookup table, just like vtkMapper does.  Really, vtkTexture
>>> is, itself, very much like a mapper.  The rules for how vtkTexture
>>> maps the input data into something that can be used by the hardware
>>> are described in the class documentation.
>>>
>>>   David
>>
>> David G,
>>
>> I was looking here:
>> http://www.vtk.org/doc/nightly/html/classvtkTexture.html#_details and
>> I still don't see anything about the rules it uses?
>>
>> I checked this:
>>
>> vtkstd::cout << "Map through LUT? " <<
>> myTexture->GetMapColorScalarsThroughLookupTable () << vtkstd::endl;
>>
>> and it is 0, so that should mean that the image should be displayed
>> based on its actual RGB values, right? I must still be
>> misunderstanding.
>>
>> Thanks,
>>
>> David D.
>> _______________________________________________
>> 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
>>
>

David G,

I guess I still don't follow you why it is so bad to create an image
the way I had? I'll trust you though and I changed it to use a
vtkImageCanvasSource2D to generate the blank image (I had to use
FillBox on the whole image though because it wasn't initialized).

Now the image is black, but the circle is white (where it should be
red from drawing->SetDrawColor(255, 0, 0, 0.5) )

Learning from previous mistakes, I first checked the source code.
http://www.cmake.org/Wiki/VTK_Examples_Drawing_shapes_in_an_image

void vtkImageCanvasSource2D::DrawCircle(int c0, int c1, double radius)
seems to call another version of DrawCircle passing it this->DrawColor
which I have verified is being set correctly with:

drawing->SetDrawColor(255, 0, 0, 0.5);
double drawColor[4];
drawing->GetDrawColor(drawColor);
std::cout << "drawColor: " << drawColor[0] << " " << drawColor[1] << "
" << drawColor[2] << " " << drawColor[3] << std::endl;
drawing->DrawCircle(9, 10, 5);

I also tried many different colors (255, 0, 255) for example and the
circle was still white, so this leads me to believe I am not simply
misinterpreting the color convention or something like that. Any
thoughts on why the circle does not change colors?

Thanks,

David



More information about the vtkusers mailing list