[vtkusers] About Brightness and Contrast on a Color Image

Dean Inglis inglis.dl at gmail.com
Wed Apr 17 09:01:45 EDT 2013


Hi Alessandro,

for unsigned char 3 component images, I wrote a customized version of
vtkImageMapToWindowLevelColors to work on multi-component images.  In the
unmodified
(vtk) version of this class, only the first component of multi-component
images is modified, as described in the class documentation:

"The vtkImageMapToWindowLevelColors<http://www.vtk.org/doc/release/5.10/html/classvtkImageMapToWindowLevelColors.html>filter
will take an input image of any valid scalar type, and map the first
component of the image through a lookup table. This resulting color will be
modulated with value obtained by a window / level operation. The result is
an image of type VTK_UNSIGNED_CHAR. If the lookup table is not set, or is
set to NULL, then the input data will be passed through if it is already of
type UNSIGNED_CHAR."

here are the mods to lines 366 to 401 of vtkImageMapToWindowLevelColors.cxx
in VTK 5.10

364       else
365         {
366         for (idxX = 0; idxX < extX; idxX++)
367           {
368           for(int j = 0; j < numberOfComponents; ++j )
369             {
370             if( j == (numberOfComponents - 1 ) &&
371                 (outputFormat == VTK_LUMINANCE_ALPHA ||
372                  outputFormat == VTK_RGBA) )
373               {
374               *(optr) = 255;
375               }
376             else
377             {
378             if (*iptr <= lower)
379               {
380               result_val = lower_val;
381               }
382             else if (*iptr >= upper)
383               {
384               result_val = upper_val;
385               }
386             else
387               {
388               result_val = static_cast<unsigned char>((*iptr +
shift)*scale);
389               }
390             *optr = result_val;
391             }
392             iptr++;
393             optr++;
394             }
395           }
396         }


regards,
Dean



On Tue, Apr 16, 2013 at 5:02 PM, Alessandro <notinmyhead at gmail.com> wrote:

> Hi,
>
> I'm trying to apply Brightness and Contrast to a blended image, created
> from a Grey Image and a Color one. I set brightness and contrast via
> vtkImageViewer2 SetColorWindow and SetColorLevel methods but it doesn't
> work on the blended one: as soon as I set one of them, the image becomes a
> Grey one.
>
> Any suggestion?
>
> Thanks,
> Ale
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130417/886db572/attachment.htm>


More information about the vtkusers mailing list