Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Contrast controls

jpadfield
2006-08-22
2012-10-06
  • jpadfield
    jpadfield
    2006-08-22

    Hi,

    I just noticed something I just wanted to check on it.

    In the windows IIPImage server I just set up when you increase the CNT value you get some strange colours rather than white when the image starts to burn out. My Linux version does not do this.

    Is there a setting somewhere which controls this, it seems familiar to me but I cant remember :-)

    thanks

    Joe

     
    • Denis Pitzalis
      Denis Pitzalis
      2006-08-24

      In the 0.9.6_01 version I fixed the problem. Thanks for use (and test) IIPImage :)

       
    • jpadfield
      jpadfield
      2006-08-22

      Hi Denis,

      I have started to remember about this now. I think this was an adjustment that needed to be made to the code while building the server, it was something I discussed with Ruven.
      With 16-bit images the code limited the max value to 255 but with 8-bit images a CNT value of greater than 1 caused the RGB values to loop background and count up from 0 again, resulting in the interesting colours.

      Ruven told me before that the 8-bit code needed to be adjusted to be similar to the code for 16-bit images for you to be able to apply CNT values greater than 1 to 8-bit images.

      If this adjustment is made then increasing the CNT above 1 allows a user to brighten up an 8-bit images, basically brightening the image. This can be very useful when looking at dark images of paintings :-) .

      Would it be possible for you to make this change for the windows installer build ? :-)

      What do you think ?

      Joe

      The changes need to be made in the CVT section of Main.cc somewhere round about line 1820

      ##################### Original Code

      // If we have a 16 bit image, multiply by the contrast adjustment if it exists
      // and clip to 8 bits
      else if( rawtile.bpc == 16 ){
      unsigned short sptr = (unsigned short) rawtile.data;
      float contrast = image_transform.getContrast();
      for( n=0; n<dst_tile_widthchannels; n++ ){
      if( ( (unsigned short)sptr[inx+n] * contrast) > 255) buf[buffer_index + n] = 255;
      else buf[buffer_index + n] = (unsigned char) (( ((unsigned short)sptr[inx+n])) * contrast);
      }
      }
      else if( (rawtile.bpc == 8) && (image_transform.getContrast() != 1.0) ){
      unsigned char
      sptr = (unsigned char) rawtile.data;
      for( n=0; n<dst_tile_width
      channels; n++ ){
      buf[buffer_index + n] = (unsigned char) (sptr[inx+n] * image_transform.getContrast());
      }
      }

      ##################### Adjusted Code

      // If we have a 16 bit image, multiply by the contrast adjustment if it exists
      // and clip to 8 bits
      else if( rawtile.bpc == 16 ){
      unsigned short sptr = (unsigned short) rawtile.data;
      float contrast = image_transform.getContrast();
      for( n=0; n<dst_tile_widthchannels; n++ ){
      if( ( (unsigned short)sptr[inx+n] * contrast) > 255) buf[buffer_index + n] = 255;
      else buf[buffer_index + n] = (unsigned char) (( ((unsigned short)sptr[inx+n])) * contrast);
      }
      }
      else if( (rawtile.bpc == 8) && (image_transform.getContrast() != 1.0) ){
      unsigned char
      sptr = (unsigned char) rawtile.data;
      float contrast = image_transform.getContrast();
      for( n=0; n<dst_tile_width
      channels; n++ ){
      if( ( (unsigned short)sptr[inx+n] * contrast) > 255) buf[buffer_index + n] = 255;
      else buf[buffer_index + n] = (unsigned char) (( ((unsigned short)sptr[inx+n])) * contrast);
      }

      #######################################################################
       
      • jpadfield
        jpadfield
        2006-08-22

        hi joe!

        a more simple solution will be:
        // If we have a 16 bit image, multiply by the contrast adjustment if it
        exists
        // and clip to 8 bits
        else if( rawtile.bpc == 16 ){
        unsigned short sptr = (unsigned short)
        rawtile.data;
        float contrast = image_transform.getContrast();
        for( n=0; n<dst_tile_widthchannels; n++ ){
        if( ( (unsigned short)sptr[inx+n] * contrast) >
        255) buf[buffer_index + n] = 255;
        else buf[buffer_index + n] = (unsigned char)
        (( ((unsigned short)sptr[inx+n])) * contrast);
        }
        }
        else if( (rawtile.bpc == 8) &&
        (image_transform.getContrast() != 1.0) ){
        unsigned char
        sptr = (unsigned char) rawtile.data;
        for( n=0; n<dst_tile_width
        channels; n++ ){
        float v = (float)sptr[inx+n]
        image_transform.getContrast();
        if( v > 255.0 ) v = 255.0;
        buf[buffer_index + n] = (unsigned char) v;
        }
        }
        else{
        memcpy( &buf[buffer_index], &ptr[inx],
        dst_tile_width
        channels );
        }
        }

        ciao ciao,
        Denis

         


Anonymous


Cancel   Add attachments