image - Calculating Brightness and Contrast similar to new Adobe Photoshop or Lightroom functions -


i trying create brightness , contrast filters similar new adobe photoshop or lightroom brightness , contrast filters. doing rgb -> xyz - xyy conversion , increasing pixel brightness (y) ( not linear increase, brightness increase calculated depending on pixels brightness) , converting xyz , rgb trying similar possible values test image used increase brightness in adobe. not getting similar results think missing something, maybe gamma calculation or images in srgb space color space conversion, or simple have bug in color conversion code? here color conversion function used (in objective-c) :

-(void) convertrgbcolor:(ccolorrgb*) prgb toxyzcolor:(zcolorxyz*) pxyz {     if(prgb == nil || pxyz == nil) {         return;     }      double var_r = ( prgb->r / 255.0 );     double var_g = ( prgb->g / 255.0 );     double var_b = ( prgb->b / 255.0 );      if ( var_r > 0.04045 ) var_r = pow((( var_r + 0.055 ) / 1.055 ) , 2.4);     else                   var_r = var_r / 12.92;     if ( var_g > 0.04045 ) var_g = pow((( var_g + 0.055 ) / 1.055 ) , 2.4);     else                   var_g = var_g / 12.92;     if ( var_b > 0.04045 ) var_b = pow((( var_b + 0.055 ) / 1.055 ) , 2.4);     else                   var_b = var_b / 12.92;      var_r = var_r * 100;     var_g = var_g * 100;     var_b = var_b * 100;      //observer. = 2°, illuminant = d65     pxyz->x = var_r * 0.4124 + var_g * 0.3576 + var_b * 0.1805;     pxyz->y = var_r * 0.2126 + var_g * 0.7152 + var_b * 0.0722;     pxyz->z = var_r * 0.0193 + var_g * 0.1192 + var_b * 0.9505; }  -(void) convertxyzcolor:(zcolorxyz*) pxyz torgbcolor:(ccolorrgb*) prgb {     if(prgb == nil || pxyz == nil) {         return;     }      double var_x = pxyz->x / 100;        //x 0  95.047     double var_y = pxyz->y / 100;        //y 0 100.000     double var_z = pxyz->z / 100;        //z 0 108.883      double var_r = var_x *  3.2406 + var_y * -1.5372 + var_z * -0.4986;     double var_g = var_x * -0.9689 + var_y *  1.8758 + var_z *  0.0415;     double var_b = var_x *  0.0557 + var_y * -0.2040 + var_z *  1.0570;      if ( var_r > 0.0031308 ) var_r = 1.055 * ( pow( var_r,(1/2.4))) - 0.055;     else                     var_r = 12.92 * var_r;     if ( var_g > 0.0031308 ) var_g = 1.055 * ( pow( var_g,(1/2.4))) - 0.055;     else                     var_g = 12.92 * var_g;     if ( var_b > 0.0031308 ) var_b = 1.055 * ( pow( var_b,(1/2.4))) - 0.055;     else                     var_b = 12.92 * var_b;      prgb->r = var_r * 255;     prgb->g = var_g * 255;     prgb->b = var_b * 255; }  -(void) convertyxycolor:(zcoloryxy*) pyxy toxyzcolor:(zcolorxyz*) pxyz {     if(pyxy == nil || pxyz == nil) {         return;     }      pxyz->x = pyxy->x * ( pyxy->y / pyxy->y );     pxyz->y = pyxy->y;     pxyz->z = ( 1 - pyxy->x - pyxy->y ) * ( pyxy->y / pyxy->y ); }  -(void) convertxyzcolor:(zcolorxyz*) pxyz toyxycolor:(zcoloryxy*) pyxy {     if(pyxy == nil || pxyz == nil) {         return;     }      pyxy->y = pxyz->y;     pyxy->x = pxyz->x / ( pxyz->x + pxyz->y + pxyz->z );     pyxy->y = pxyz->y / ( pxyz->x + pxyz->y + pxyz->z ); } 


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -