more
This commit is contained in:
parent
e443f53b97
commit
3a8a264578
@ -240,12 +240,9 @@ im_max( IMAGE *in, double *out )
|
||||
inf.out = out;
|
||||
inf.valid = 0;
|
||||
|
||||
if( im_pincheck( in ) )
|
||||
if( im_pincheck( in ) ||
|
||||
im_check_uncoded( "im_max", in ) )
|
||||
return( -1 );
|
||||
if( in->Coding != IM_CODING_NONE ) {
|
||||
im_error( "im_max", "%s", _( "not uncoded" ) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if( im_iterate( in, max_start, max_scan, max_stop, &inf, NULL ) )
|
||||
return( -1 );
|
||||
|
@ -1,14 +1,4 @@
|
||||
/* @(#) Function to find the maximum of an image. Returns coords and value at
|
||||
* @(#) double precision. In the event of a draw, returns average of all
|
||||
* @(#) drawing coords, and interpolated value at that position.
|
||||
* @(#)
|
||||
* @(#) int im_maxpos_avg(
|
||||
* @(#) IMAGE *im,
|
||||
* @(#) double *xpos,
|
||||
* @(#) double *ypos,
|
||||
* @(#) double *out
|
||||
* @(#) );
|
||||
* @(#)
|
||||
/* im_maxpos_avg.c
|
||||
*
|
||||
* Copyright: 2006, The Nottingham Trent University
|
||||
* Copyright: 2006, Tom Vajzovic
|
||||
@ -20,6 +10,8 @@
|
||||
* - changed spelling of occurrences
|
||||
* - check for !occurrences before using val
|
||||
* - renamed avg as sum, a bit clearer
|
||||
* 2/9/09
|
||||
* - gtkdoc comment
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -83,30 +75,37 @@ static int maxpos_avg_stop( void *seq, void *, void * );
|
||||
|
||||
/** EXPORTED FUNCTION **/
|
||||
|
||||
/**
|
||||
* im_maxpos_avg:
|
||||
* @im: image to scan
|
||||
* @xpos: returned X position
|
||||
* @ypos: returned Y position
|
||||
* @out: returned value
|
||||
*
|
||||
* Function to find the maximum of an image. Returns coords and value at
|
||||
* double precision. In the event of a draw, returns average of all
|
||||
* drawing coords, and interpolated value at that position.
|
||||
*
|
||||
* See also: im_maxpos(), im_min(), im_stats().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int im_maxpos_avg( IMAGE *im, double *xpos, double *ypos, double *out ){
|
||||
#define FUNCTION_NAME "im_maxpos_avg"
|
||||
|
||||
pos_avg_t master= { 0.0, 0.0, 0.0, 0 };
|
||||
|
||||
if( im_pincheck( im ) )
|
||||
if( im_pincheck( im ) ||
|
||||
im_check_uncoded( FUNCTION_NAME, im ) ||
|
||||
im_check_noncomplex( FUNCTION_NAME, im ) ||
|
||||
im_check_mono( FUNCTION_NAME, im ) )
|
||||
return -1;
|
||||
|
||||
if( im-> Coding ){
|
||||
im_error( FUNCTION_NAME, "%s", _("uncoded images only") );
|
||||
return -1;
|
||||
}
|
||||
if( !( im_isint( im ) || im_isfloat( im ) ) ){
|
||||
im_error( FUNCTION_NAME, "%s", _("scalar images only") );
|
||||
return -1;
|
||||
}
|
||||
if( 1 != im-> Bands ){
|
||||
im_error( FUNCTION_NAME, "%s", _("single band images only") );
|
||||
return -1;
|
||||
}
|
||||
if( ! xpos || ! ypos || ! out ){
|
||||
im_error( FUNCTION_NAME, "%s", _("invalid argument") );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( im_iterate( im, maxpos_avg_start, maxpos_avg_scan, maxpos_avg_stop, &master, NULL ) )
|
||||
return -1;
|
||||
|
||||
|
@ -141,6 +141,7 @@ int im_check_bands_1orn( const char *domain, IMAGE *im1, IMAGE *im2 );
|
||||
int im_check_noncomplex( const char *domain, IMAGE *im );
|
||||
int im_check_complex( const char *domain, IMAGE *im );
|
||||
int im_check_uchar( const char *domain, IMAGE *im );
|
||||
int im_check_mono( const char *domain, IMAGE *im );
|
||||
int im_check_int( const char *domain, IMAGE *im );
|
||||
int im_check_size( const char *domain, IMAGE *im1, IMAGE *im2 );
|
||||
int im_check_bands( const char *domain, IMAGE *im1, IMAGE *im2 );
|
||||
|
@ -417,6 +417,17 @@ im_check_uchar( const char *domain, IMAGE *im )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
im_check_mono( const char *domain, IMAGE *im )
|
||||
{
|
||||
if( im->Bands != 1 ) {
|
||||
im_error( domain, "%s", _( "image must one band" ) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
im_check_int( const char *domain, IMAGE *im )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user