sync
This commit is contained in:
parent
844ee2c13f
commit
9493ea7e29
7
TODO
7
TODO
@ -1,9 +1,4 @@
|
||||
- max is broken
|
||||
|
||||
$ ~/vips-7.26/bin/vips-7.26 vips im_max sarto_ng.tif
|
||||
255
|
||||
$ vips max sarto_ng.tif
|
||||
165.000000
|
||||
- im_open_local() is broken? try Adam's prog under 7.27
|
||||
|
||||
|
||||
|
||||
|
@ -74,10 +74,14 @@
|
||||
* @out: image of statistics
|
||||
*
|
||||
* Find many image statistics in a single pass through the data. @out is a
|
||||
* one-band #VIPS_FORMAT_DOUBLE image
|
||||
* of 6 columns by n + 1 (where n is number of bands in image @in)
|
||||
* one-band #VIPS_FORMAT_DOUBLE image of at least 10 columns by n + 1
|
||||
* (where n is number of bands in image @in)
|
||||
* 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.
|
||||
*
|
||||
* See also: #VipsAvg, #VipsMin, and friends.
|
||||
@ -90,9 +94,6 @@ typedef struct _VipsStats {
|
||||
|
||||
VipsImage *out;
|
||||
|
||||
or build out and use that as an array?
|
||||
|
||||
double **stats;
|
||||
} VipsStats;
|
||||
|
||||
typedef VipsStatisticClass VipsStatsClass;
|
||||
@ -108,6 +109,14 @@ vips_stats_build( VipsObject *object )
|
||||
gint64 vals;
|
||||
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 ) )
|
||||
return( -1 );
|
||||
|
||||
@ -121,7 +130,6 @@ vips_stats_build( VipsObject *object )
|
||||
average = stats->sum / vals;
|
||||
if( vips_bandfmt_iscomplex( vips_image_get_format( statistic->in ) ) )
|
||||
average = sqrt( average );
|
||||
g_object_set( object, "out", average, NULL );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -469,6 +469,7 @@ VipsImage *vips_image_new_from_file_raw( const char *filename,
|
||||
int xsize, int ysize, int bands, int offset );
|
||||
VipsImage *vips_image_new_from_memory( void *buffer,
|
||||
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,
|
||||
gboolean delete_on_close );
|
||||
VipsImage *vips_image_new_disc_temp( const char *format );
|
||||
|
@ -1615,6 +1615,47 @@ vips_image_new_from_memory( void *buffer,
|
||||
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:
|
||||
* @image: image to set
|
||||
@ -1843,8 +1884,8 @@ vips__image_write_prepare( VipsImage *image )
|
||||
case VIPS_IMAGE_SETBUF:
|
||||
/* Allocate memory.
|
||||
*/
|
||||
if( !image->data )
|
||||
if( !(image->data = vips_tracked_malloc(
|
||||
if( !image->data &&
|
||||
!(image->data = vips_tracked_malloc(
|
||||
VIPS_IMAGE_SIZEOF_IMAGE( image ))) )
|
||||
return( -1 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user