static int ifthenelse( IMAGE *c, IMAGE *a, IMAGE *b, IMAGE *out ) { IMAGE **in; /* Check args. */ if( im_check_uncoded( "im_ifthenelse", c ) || im_check_coding_known( "im_ifthenelse", a ) || im_check_coding_known( "im_ifthenelse", b ) || im_check_format( "ifthenelse", c, IM_BANDFMT_UCHAR ) || im_check_format_same( "ifthenelse", a, b ) || im_check_bands_same( "ifthenelse", a, b ) || im_check_bands_1orn( "im_ifthenelse", c, a ) || im_piocheck( c, out ) || im_pincheck( a ) || im_pincheck( b ) ) return( -1 ); /* Make output image. */ if( im_demand_hint( out, IM_THINSTRIP, c, a, b, NULL ) || im_cp_descv( out, a, b, c, NULL ) || !(in = im_allocate_input_array( out, c, a, b, NULL )) || im_generate( out, im_start_many, ifthenelse_gen, im_stop_many, in, NULL ) ) return( -1 ); return( 0 ); }
/* Raw fastcor, with no borders. */ int im_fastcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out ) { /* PIO between in and out; WIO from ref. */ if( im_piocheck( in, out ) || im_incheck( ref ) ) return( -1 ); /* Check sizes. */ if( in->Xsize < ref->Xsize || in->Ysize < ref->Ysize ) { im_error( "im_fastcor", "%s", _( "ref not smaller than or equal to in" ) ); return( -1 ); } /* Check types. */ if( im_check_uncoded( "im_fastcor", in ) || im_check_mono( "im_fastcor", in ) || im_check_format( "im_fastcor", in, IM_BANDFMT_UCHAR ) || im_check_coding_same( "im_fastcor", in, ref ) || im_check_bands_same( "im_fastcor", in, ref ) || im_check_format_same( "im_fastcor", in, ref ) ) return( -1 ); /* Prepare the output image. */ if( im_cp_descv( out, in, ref, NULL ) ) return( -1 ); out->BandFmt = IM_BANDFMT_UINT; out->Xsize = in->Xsize - ref->Xsize + 1; out->Ysize = in->Ysize - ref->Ysize + 1; /* FATSTRIP is good for us, as THINSTRIP will cause * too many recalculations on overlaps. */ if( im_demand_hint( out, IM_FATSTRIP, in, NULL ) || im_generate( out, im_start_one, fastcor_gen, im_stop_one, in, ref ) ) return( -1 ); out->Xoffset = -ref->Xsize / 2; out->Yoffset = -ref->Ysize / 2; return( 0 ); }