add vips_image_new_matrixv()
This commit is contained in:
parent
a51681f490
commit
481a4445fb
@ -17,6 +17,7 @@
|
||||
- added vips_webpload(), vips_webpload_buffer(), vips_webpsave(),
|
||||
vips_webpsave_buffer(), vips_webpsave_mime()
|
||||
- tiff reader allows separate planes for strip read
|
||||
- added vips_image_new_matrixv()
|
||||
|
||||
3/7/13 started 7.34.2
|
||||
- lower priority for Matlab load to reduce segvs from Mat_Open(), thanks
|
||||
|
2
TODO
2
TODO
@ -1,5 +1,7 @@
|
||||
- finish hist_ismonotonic()
|
||||
|
||||
needs im_conv()
|
||||
|
||||
- need to do im_profile() before we can finish hist_percent()
|
||||
|
||||
- try:
|
||||
|
@ -63,11 +63,13 @@ typedef struct _VipsHistIsmonotonic {
|
||||
|
||||
typedef VipsOperationClass VipsHistIsmonotonicClass;
|
||||
|
||||
G_DEFINE_TYPE( VipsHistIsmonotonic, vips_hist_ismonotonic, VIPS_TYPE_OPERATION );
|
||||
G_DEFINE_TYPE( VipsHistIsmonotonic, vips_hist_ismonotonic,
|
||||
VIPS_TYPE_OPERATION );
|
||||
|
||||
static int
|
||||
vips_hist_ismonotonic_build( VipsObject *object )
|
||||
{
|
||||
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
|
||||
VipsHistIsmonotonic *ismonotonic = (VipsHistIsmonotonic *) object;
|
||||
VipsImage **t = (VipsImage **) vips_object_local_array( object, 4 );
|
||||
|
||||
@ -75,17 +77,14 @@ vips_hist_ismonotonic_build( VipsObject *object )
|
||||
build( object ) )
|
||||
return( -1 );
|
||||
|
||||
if( im_check_hist( "im_ismonotonic", lut ) ||
|
||||
im_open_local_array( lut, t, 2, "im_ismonotonic", "p" ) )
|
||||
if( vips_check_hist( class->nickname, ismonotonic->in ) )
|
||||
return( -1 );
|
||||
|
||||
if( lut->Xsize == 1 )
|
||||
mask = im_create_imaskv( "im_ismonotonic", 1, 2, -1, 1 );
|
||||
if( ismonotonic->in->Xsize == 1 )
|
||||
t[0] = vips_image_new_matrixv( 1, 2, -1, 1 );
|
||||
else
|
||||
mask = im_create_imaskv( "im_ismonotonic", 2, 1, -1, 1 );
|
||||
if( !(mask = im_local_imask( lut, mask )) )
|
||||
return( -1 );
|
||||
mask->offset = 128;
|
||||
t[0] = vips_image_new_matrixv( 2, 1, -1, 1 );
|
||||
vips_image_set_double( t[0], "offset", 128 );
|
||||
|
||||
/* We want >=128 everywhere, ie. no -ve transitions.
|
||||
*/
|
||||
@ -133,13 +132,12 @@ vips_hist_ismonotonic_init( VipsHistIsmonotonic *ismonotonic )
|
||||
}
|
||||
|
||||
/**
|
||||
* im_ismonotonic:
|
||||
* @lut: lookup-table to test
|
||||
* @out: set non-zero if @lut is monotonic
|
||||
* vips_ismonotonic:
|
||||
* @in: lookup-table to test
|
||||
* @out: set non-zero if @in is monotonic
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Test @lut for monotonicity. @out is set non-zero if @lut is monotonic.
|
||||
*
|
||||
* See also: im_tone_build_range().
|
||||
* Test @in for monotonicity. @out is set non-zero if @in is monotonic.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
|
@ -519,7 +519,8 @@ VipsImage *vips_image_new_from_file_raw( const char *filename,
|
||||
int xsize, int ysize, int bands, guint64 offset );
|
||||
VipsImage *vips_image_new_from_memory( void *buffer,
|
||||
int xsize, int ysize, int bands, VipsBandFormat bandfmt );
|
||||
VipsImage *vips_image_new_matrix( int xsize, int ysize );
|
||||
VipsImage *vips_image_new_matrix( int width, int height );
|
||||
VipsImage *vips_image_new_matrixv( int width, int height, ... );
|
||||
void vips_image_set_delete_on_close( VipsImage *image,
|
||||
gboolean delete_on_close );
|
||||
VipsImage *vips_image_new_temp_file( const char *format );
|
||||
|
@ -1637,18 +1637,22 @@ vips_image_new_from_memory( void *buffer,
|
||||
|
||||
/**
|
||||
* vips_image_new_matrix:
|
||||
* @xsize: image width
|
||||
* @ysize: image height
|
||||
* @width: image width
|
||||
* @height: image height
|
||||
*
|
||||
* This convenience function makes an image which is a matrix: a one-band
|
||||
* VIPS_FORMAT_DOUBLE image held in memory.
|
||||
*
|
||||
* Use VIPS_IMAGE_ADDR(), or VIPS_MATRIX() to address pixels in the image.
|
||||
*
|
||||
* Use vips_image_set_double() to set "scale" and "offset", if required.
|
||||
*
|
||||
* See also: vips_image_new_matrixv()
|
||||
*
|
||||
* Returns: the new #VipsImage, or %NULL on error.
|
||||
*/
|
||||
VipsImage *
|
||||
vips_image_new_matrix( int xsize, int ysize )
|
||||
vips_image_new_matrix( int width, int height )
|
||||
{
|
||||
VipsImage *image;
|
||||
|
||||
@ -1658,8 +1662,8 @@ vips_image_new_matrix( int xsize, int ysize )
|
||||
g_object_set( image,
|
||||
"filename", "vips_image_new_matrix",
|
||||
"mode", "t",
|
||||
"width", xsize,
|
||||
"height", ysize,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"bands", 1,
|
||||
"format", VIPS_FORMAT_DOUBLE,
|
||||
"interpretation", VIPS_INTERPRETATION_MATRIX,
|
||||
@ -1677,6 +1681,40 @@ vips_image_new_matrix( int xsize, int ysize )
|
||||
return( image );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_image_new_matrixv:
|
||||
* @width: image width
|
||||
* @height: image height
|
||||
* @...: matrix coefficients
|
||||
*
|
||||
* As vips_image_new_matrix(), but initialise the matrix from the argument
|
||||
* list. After @height should be @width * @height double constants which are
|
||||
* used to set the matrix elements.
|
||||
*
|
||||
* See also: vips_image_new_matrix()
|
||||
*
|
||||
* Returns: the new #VipsImage, or %NULL on error.
|
||||
*/
|
||||
VipsImage *
|
||||
vips_image_new_matrixv( int width, int height, ... )
|
||||
{
|
||||
va_list ap;
|
||||
VipsImage *matrix;
|
||||
int x, y;
|
||||
|
||||
vips_check_init();
|
||||
|
||||
matrix = vips_image_new_matrix( width, height );
|
||||
|
||||
va_start( ap, height );
|
||||
for( y = 0; y < height; y++ )
|
||||
for( x = 0; x < width; x++ )
|
||||
*VIPS_MATRIX( matrix, x, y ) = va_arg( ap, double );
|
||||
va_end( ap );
|
||||
|
||||
return( matrix );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_image_set_delete_on_close:
|
||||
* @image: image to set
|
||||
|
Loading…
Reference in New Issue
Block a user