/* A colour difference operation. */ int im__colour_difference( const char *domain, IMAGE *in1, IMAGE *in2, IMAGE *out, im_wrapmany_fn buffer_fn, void *a, void *b ) { IMAGE *t[3]; if( im_check_uncoded( domain, in1 ) || im_check_uncoded( domain, in2 ) || im_check_bands( domain, in1, 3 ) || im_check_bands( domain, in2, 3 ) || im_check_size_same( domain, in1, in2 ) || im_open_local_array( out, t, 2, domain, "p" ) || im_clip2fmt( in1, t[0], IM_BANDFMT_FLOAT ) || im_clip2fmt( in2, t[1], IM_BANDFMT_FLOAT ) ) return( -1 ); if( im_cp_descv( out, t[0], t[1], NULL ) ) return( -1 ); out->Bands = 1; out->Type = IM_TYPE_B_W; t[2] = NULL; if( im_wrapmany( t, out, buffer_fn, a, b ) ) return( -1 ); return( 0 ); }
/** * im_LabS2LabQ: * @in: input image * @out: output image * * Convert a LabS three-band signed short image to LabQ * * See also: im_LabQ2LabS(). * * Returns: 0 on success, -1 on error. */ int im_LabS2LabQ( IMAGE *in, IMAGE *out ) { IMAGE *t[1]; if( im_check_uncoded( "im_LabS2LabQ", in ) || im_check_bands( "im_LabS2LabQ", in, 3 ) || im_open_local_array( out, t, 1, "im_LabS2LabQ", "p" ) || im_clip2fmt( in, t[0], IM_BANDFMT_SHORT ) ) return( -1 ); /* Set up output image */ if( im_cp_desc( out, in ) ) return( -1 ); out->Bands = 4; out->Type = IM_TYPE_LABQ; out->BandFmt = IM_BANDFMT_UCHAR; out->Coding = IM_CODING_LABQ; if( im_wrapone( in, out, (im_wrapone_fn) imb_LabS2LabQ, NULL, NULL ) ) return( -1 ); return( 0 ); }
/** * im_tone_analyse: * @in: input image * @out: output image * @Ps: shadow point (eg. 0.2) * @Pm: mid-tone point (eg. 0.5) * @Ph: highlight point (eg. 0.8) * @S: shadow adjustment (+/- 30) * @M: mid-tone adjustment (+/- 30) * @H: highlight adjustment (+/- 30) * * As im_tone_build(), but analyse the histogram of @in and use it to * pick the 0.1% and 99.9% points for @Lb and @Lw. * * See also: im_tone_build(). * * Returns: 0 on success, -1 on error */ int im_tone_analyse( IMAGE *in, IMAGE *out, double Ps, double Pm, double Ph, double S, double M, double H ) { IMAGE *t[4]; int low, high; double Lb, Lw; if( im_open_local_array( out, t, 4, "im_tone_map", "p" ) ) return( -1 ); /* If in is IM_CODING_LABQ, unpack. */ if( in->Coding == IM_CODING_LABQ ) { if( im_LabQ2LabS( in, t[0] ) ) return( -1 ); } else t[0] = in; /* Should now be 3-band short. */ if( im_check_uncoded( "im_tone_analyse", t[0] ) || im_check_bands( "im_tone_analyse", t[0], 3 ) || im_check_format( "im_tone_analyse", t[0], IM_BANDFMT_SHORT ) ) return( -1 ); if( im_extract_band( t[0], t[1], 0 ) || im_clip2fmt( t[1], t[2], IM_BANDFMT_USHORT ) || im_histgr( t[2], t[3], -1 ) ) return( -1 ); if( im_mpercent_hist( t[3], 0.1 / 100.0, &high ) || im_mpercent_hist( t[3], 99.9 / 100.0, &low ) ) return( -1 ); Lb = 100 * low / 32768; Lw = 100 * high / 32768; im_diag( "im_tone_analyse", "set Lb = %g, Lw = %g", Lb, Lw ); return( im_tone_build( out, Lb, Lw, Ps, Pm, Ph, S, M, H ) ); }
int im__colour_unary( const char *domain, IMAGE *in, IMAGE *out, VipsType type, im_wrapone_fn buffer_fn, void *a, void *b ) { IMAGE *t[1]; if( im_check_uncoded( domain, in ) || im_check_bands( domain, in, 3 ) || im_open_local_array( out, t, 1, domain, "p" ) || im_clip2fmt( in, t[0], IM_BANDFMT_FLOAT ) ) return( -1 ); if( im_cp_desc( out, t[0] ) ) return( -1 ); out->Type = type; if( im_wrapone( t[0], out, (im_wrapone_fn) buffer_fn, a, b ) ) return( -1 ); return( 0 ); }