sync
This commit is contained in:
parent
844ee2c13f
commit
9493ea7e29
7
TODO
7
TODO
@ -1,9 +1,4 @@
|
|||||||
- max is broken
|
- im_open_local() is broken? try Adam's prog under 7.27
|
||||||
|
|
||||||
$ ~/vips-7.26/bin/vips-7.26 vips im_max sarto_ng.tif
|
|
||||||
255
|
|
||||||
$ vips max sarto_ng.tif
|
|
||||||
165.000000
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,10 +74,14 @@
|
|||||||
* @out: image of statistics
|
* @out: image of statistics
|
||||||
*
|
*
|
||||||
* Find many image statistics in a single pass through the data. @out is a
|
* Find many image statistics in a single pass through the data. @out is a
|
||||||
* one-band #VIPS_FORMAT_DOUBLE image
|
* one-band #VIPS_FORMAT_DOUBLE image of at least 10 columns by n + 1
|
||||||
* of 6 columns by n + 1 (where n is number of bands in image @in)
|
* (where n is number of bands in image @in)
|
||||||
* rows. Columns are statistics, and are, in order: minimum, maximum, sum,
|
* rows. Columns are statistics, and are, in order: minimum, maximum, sum,
|
||||||
* sum of squares, mean, standard deviation. Row 0 has statistics for all
|
* sum of squares, mean, standard deviation, x coordinate of minimum, y
|
||||||
|
* coordinate of minimum, x coordinate of maximum, y coordinate of maximum.
|
||||||
|
* Later versions of VipsStats may add more columns.
|
||||||
|
*
|
||||||
|
* Row 0 has statistics for all
|
||||||
* bands together, row 1 has stats for band 1, and so on.
|
* bands together, row 1 has stats for band 1, and so on.
|
||||||
*
|
*
|
||||||
* See also: #VipsAvg, #VipsMin, and friends.
|
* See also: #VipsAvg, #VipsMin, and friends.
|
||||||
@ -90,9 +94,6 @@ typedef struct _VipsStats {
|
|||||||
|
|
||||||
VipsImage *out;
|
VipsImage *out;
|
||||||
|
|
||||||
or build out and use that as an array?
|
|
||||||
|
|
||||||
double **stats;
|
|
||||||
} VipsStats;
|
} VipsStats;
|
||||||
|
|
||||||
typedef VipsStatisticClass VipsStatsClass;
|
typedef VipsStatisticClass VipsStatsClass;
|
||||||
@ -108,6 +109,14 @@ vips_stats_build( VipsObject *object )
|
|||||||
gint64 vals;
|
gint64 vals;
|
||||||
double average;
|
double average;
|
||||||
|
|
||||||
|
if( statistic->in ) {
|
||||||
|
int bands = vips_image_get_bands( statistic->in->Bands );
|
||||||
|
|
||||||
|
g_object_set( object,
|
||||||
|
"out", vips_image_new_array( 10, bands + 1 ),
|
||||||
|
NULL );
|
||||||
|
}
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_stats_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_stats_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
@ -121,7 +130,6 @@ vips_stats_build( VipsObject *object )
|
|||||||
average = stats->sum / vals;
|
average = stats->sum / vals;
|
||||||
if( vips_bandfmt_iscomplex( vips_image_get_format( statistic->in ) ) )
|
if( vips_bandfmt_iscomplex( vips_image_get_format( statistic->in ) ) )
|
||||||
average = sqrt( average );
|
average = sqrt( average );
|
||||||
g_object_set( object, "out", average, NULL );
|
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -469,6 +469,7 @@ VipsImage *vips_image_new_from_file_raw( const char *filename,
|
|||||||
int xsize, int ysize, int bands, int offset );
|
int xsize, int ysize, int bands, int offset );
|
||||||
VipsImage *vips_image_new_from_memory( void *buffer,
|
VipsImage *vips_image_new_from_memory( void *buffer,
|
||||||
int xsize, int ysize, int bands, VipsBandFormat bandfmt );
|
int xsize, int ysize, int bands, VipsBandFormat bandfmt );
|
||||||
|
VipsImage *vips_image_new_array( int xsize, int ysize );
|
||||||
void vips_image_set_delete_on_close( VipsImage *image,
|
void vips_image_set_delete_on_close( VipsImage *image,
|
||||||
gboolean delete_on_close );
|
gboolean delete_on_close );
|
||||||
VipsImage *vips_image_new_disc_temp( const char *format );
|
VipsImage *vips_image_new_disc_temp( const char *format );
|
||||||
|
@ -1615,6 +1615,47 @@ vips_image_new_from_memory( void *buffer,
|
|||||||
return( image );
|
return( image );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vips_image_new_array:
|
||||||
|
* @xsize: image width
|
||||||
|
* @ysize: image height
|
||||||
|
*
|
||||||
|
* This convenience function makes an image which is an array: a one-band
|
||||||
|
* VIPS_FORMAT_DOUBLE image held in memory.
|
||||||
|
*
|
||||||
|
* Use VIPS_IMAGE_ADDR() to address pixels in the image.
|
||||||
|
*
|
||||||
|
* Returns: the new #VipsImage, or %NULL on error.
|
||||||
|
*/
|
||||||
|
VipsImage *
|
||||||
|
vips_image_new_array( int xsize, int ysize )
|
||||||
|
{
|
||||||
|
VipsImage *image;
|
||||||
|
|
||||||
|
vips_check_init();
|
||||||
|
|
||||||
|
image = VIPS_IMAGE( g_object_new( VIPS_TYPE_IMAGE, NULL ) );
|
||||||
|
g_object_set( image,
|
||||||
|
"filename", "vips_image_new_array",
|
||||||
|
"mode", "t",
|
||||||
|
"width", xsize,
|
||||||
|
"height", ysize,
|
||||||
|
"bands", 1,
|
||||||
|
"format", VIPS_FORMAT_DOUBLE,
|
||||||
|
NULL );
|
||||||
|
if( vips_object_build( VIPS_OBJECT( image ) ) ) {
|
||||||
|
VIPS_UNREF( image );
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( vips__image_write_prepare( image ) ) {
|
||||||
|
g_object_unref( image );
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( image );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_image_set_delete_on_close:
|
* vips_image_set_delete_on_close:
|
||||||
* @image: image to set
|
* @image: image to set
|
||||||
@ -1843,10 +1884,10 @@ vips__image_write_prepare( VipsImage *image )
|
|||||||
case VIPS_IMAGE_SETBUF:
|
case VIPS_IMAGE_SETBUF:
|
||||||
/* Allocate memory.
|
/* Allocate memory.
|
||||||
*/
|
*/
|
||||||
if( !image->data )
|
if( !image->data &&
|
||||||
if( !(image->data = vips_tracked_malloc(
|
!(image->data = vips_tracked_malloc(
|
||||||
VIPS_IMAGE_SIZEOF_IMAGE( image ))) )
|
VIPS_IMAGE_SIZEOF_IMAGE( image ))) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user