ifthenelse allows non-uchar conditional images

This commit is contained in:
John Cupitt 2010-06-25 13:04:21 +00:00
parent 2cbaf93b18
commit 5fae2763a5
3 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,7 @@
12/5/10 started 7.22.2
- the conditional image of ifthenelse can be any format, a (!=0) is added if
necessary
12/5/10 started 7.22.1
- fix a problem with tiff pyramid write and >1cpu, thanks Ruven
- constant ops clip to target range

View File

@ -6,7 +6,7 @@ AC_CONFIG_MACRO_DIR(m4)
# user-visible library versioning
m4_define([vips_major_version], [7])
m4_define([vips_minor_version], [22])
m4_define([vips_micro_version], [1])
m4_define([vips_micro_version], [2])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -29,7 +29,7 @@ PACKAGE=vips
# interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=29
LIBRARY_REVISION=2
LIBRARY_REVISION=3
LIBRARY_AGE=14
AM_INIT_AUTOMAKE($PACKAGE,$VERSION)

View File

@ -15,6 +15,9 @@
* - use im_check*()
* - allow many-band conditional and single-band a/b
* - allow a/b to differ in format and bands
* 25/6/10
* - let the conditional image be any format by adding a (!=0) if
* necessary
*/
/*
@ -185,7 +188,7 @@ ifthenelse( IMAGE *c, IMAGE *a, IMAGE *b, IMAGE *out )
* @b: else #IMAGE
* @out: output #IMAGE
*
* This operation scans the condition image @c (which must be unsigned char)
* This operation scans the condition image @c
* and uses it to select pixels from either the then image @a or the else
* image @b. Non-zero means @a, 0 means @b.
*
@ -216,6 +219,15 @@ im_ifthenelse( IMAGE *c, IMAGE *a, IMAGE *b, IMAGE *out )
im__bandalike( t[0], t[1], t[2], t[3] ) )
return( -1 );
/* If c is not uchar, do (!=0) to make a uchar image.
*/
if( c->BandFmt != IM_BANDFMT_UCHAR ) {
if( im_notequalconst( c, t[4], 0 ) )
return( -1 );
c = t[4];
}
if( ifthenelse( c, t[2], t[3], out ) )
return( -1 );