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 = (INTMASK *) im_local( out, (im_construct_fn) im_rotate_imask45, (im_callback_fn) im_free_imask, mask, mask->filename, NULL )) ) return( -1 ); } for( i = 0; i < 4; i++ ) if( im_abs( filtered[i], absed[i] ) ) return( -1 ); return( im_maxvalue( absed, out, 4 ) ); }
static int maxvalue_vec( im_object *argv ) { im_imagevec_object *iv = (im_imagevec_object *) argv[0]; return( im_maxvalue( iv->vec, argv[1], iv->n ) ); }
/** * im_compass: * @in: input image * @out: output image * @mask: convolution mask * * @in is convolved 8 times with @mask, each time @mask is rotated by 45 * degrees. Each output pixel is the largest absolute value of the 8 * convolutions. * * See also: im_lindetect(), im_gradient(), im_conv(). * * Returns: 0 on success, -1 on error */ int im_compass( IMAGE *in, IMAGE *out, INTMASK *mask ) { IMAGE *filtered[8]; IMAGE *absed[8]; int i; if( im_open_local_array( out, filtered, 8, "im_compass:1", "p" ) || im_open_local_array( out, absed, 8, "im_compass:2", "p" ) ) return( -1 ); for( i = 0; i < 8; 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 < 8; i++ ) if( im_abs( filtered[i], absed[i] ) ) return( -1 ); return( im_maxvalue( absed, out, 8 ) ); }