/** * im_ismonotonic: * @lut: lookup-table to test * @out: set non-zero if @lut is monotonic * * Test @lut for monotonicity. @out is set non-zero if @lut is monotonic. * * See also: im_tone_build_range(). * * Returns: 0 on success, -1 on error */ int im_ismonotonic( IMAGE *lut, int *out ) { IMAGE *t[2]; INTMASK *mask; double m; if( im_check_hist( "im_ismonotonic", lut ) || im_open_local_array( lut, t, 2, "im_ismonotonic", "p" ) ) return( -1 ); if( lut->Xsize == 1 ) mask = im_create_imaskv( "im_ismonotonic", 1, 2, -1, 1 ); else mask = im_create_imaskv( "im_ismonotonic", 2, 1, -1, 1 ); if( !(mask = im_local_imask( lut, mask )) ) return( -1 ); mask->offset = 128; /* We want >=128 everywhere, ie. no -ve transitions. */ if( im_conv( lut, t[0], mask ) || im_moreeqconst( t[0], t[1], 128 ) || im_min( t[1], &m ) ) return( -1 ); *out = m; return( 0 ); }
/** * im_gradient: * @in: input image * @out: output image * @mask: convolution mask * * @in is convolved with @mask and with @mask after a 90 degree rotation. The * result is the sum of the absolute value of the two convolutions. * * See also: im_lindetect(), im_gradient(), im_conv(). * * Returns: 0 on success, -1 on error */ int im_gradient( IMAGE *in, IMAGE *out, INTMASK *mask ) { IMAGE *t[4]; INTMASK *rmask; if( im_open_local_array( out, t, 4, "im_gradient", "p" ) ) return( -1 ); if( !(rmask = im_local_imask( out, im_rotate_imask90( mask, mask->filename ) )) ) return( -1 ); if( im_conv( in, t[0], mask ) || im_conv( in, t[1], rmask ) || im_abs( t[0], t[2] ) || im_abs( t[1], t[3] ) || im_add( t[2], t[3], out ) ) return( -1 ); return( 0 ); }
/** * im_lindetect: * @in: input image * @out: output image * @mask: convolution mask * * @in is convolved four times with @mask, each time @mask is rotated by 45 * degrees. Each output pixel is the largest absolute value of the four * convolutions. * * See also: im_compass(), im_gradient(), im_conv(). * * Returns: 0 on success, -1 on error */ int im_lindetect( IMAGE *in, IMAGE *out, INTMASK *mask ) { IMAGE *filtered[4]; IMAGE *absed[4]; int i; if( im_open_local_array( out, filtered, 4, "im_lindetect:1", "p" ) || im_open_local_array( out, absed, 4, "im_lindetect:2", "p" ) ) return( -1 ); for( i = 0; i < 4; i++ ) { if( im_conv( in, filtered[i], mask ) || !(mask = im_local_imask( out, im_rotate_imask45( mask, mask->filename ) )) ) return( -1 ); } for( i = 0; i < 4; i++ ) if( im_abs( filtered[i], absed[i] ) ) return( -1 ); return( im_maxvalue( absed, out, 4 ) ); }