[vtkusers] About Brightness and Contrast on a Color Image

Dean Inglis inglis.dl at gmail.com
Thu Apr 18 09:13:59 EDT 2013


Hi Ale,

I copied the .h and .cxx files for vtkImageMapToWindowLevelColors into a new
class, applied the patch, and added it to my application which links to
VTK: no
need to alter VTK source or re-build.

Dean


On Thu, Apr 18, 2013 at 4:43 AM, Alessandro <notinmyhead at gmail.com> wrote:

> Hi,
>
> thanks for the answer! So, if I'm not wrong, all I need to do is re-build
> the library applying the patch in advance?
>
> Do you think to submit this patch to vtk repository to include it in
> further vtk versions?
>
> Thank,
> Ale
>
> Il giorno 17/apr/2013, alle ore 15.01, Dean Inglis ha scritto:
>
> > 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 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
> >
>
> _______________________________________________
> 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/20130418/230cf733/attachment.htm>


More information about the vtkusers mailing list