improve bandalike

better setting of interpretation in output
This commit is contained in:
John Cupitt 2015-03-05 12:10:26 +00:00
parent 339f268200
commit d20f0bf617
2 changed files with 34 additions and 3 deletions

12
TODO
View File

@ -1,3 +1,15 @@
- where do we futz with interpretation? can we remove any of that now we
auto-futz in bandalike?
what about other uses of bandalike, eg. matching a one-band image to a
three-band vector, should we change anything there?
- jpegsave saves a three-band RGB image tagged as BW with three different
channels as a three-band jpg with all bands equal
cant be right!
- does cplusplus need flipver() etc.?
- are the mosaic functions calling vips_fastcor()? it must be very slow

View File

@ -382,16 +382,35 @@ vips__bandalike_vec( const char *domain,
{
int i;
int max_bands;
VipsInterpretation interpretation;
g_assert( n >= 1 );
/* We try to set the interpretation of the output images from the
* interpretation of the n-band input. For example, if we are matching
* a set of BW images to an RGB image, we want the BW images to be
* tagged as RGB.
*/
max_bands = base_bands;
for( i = 0; i < n; i++ )
max_bands = VIPS_MAX( max_bands, in[i]->Bands );
for( i = 0; i < n; i++ )
interpretation = VIPS_INTERPRETATION_ERROR;
for( i = 0; i < n; i++ ) {
/* >= so we can pick up interpretation if base_bands is equal
* to the number of bands of the largest image.
*/
if( in[i]->Bands >= max_bands ) {
max_bands = in[i]->Bands;
interpretation = in[i]->Type;
}
}
for( i = 0; i < n; i++ ) {
if( vips__bandup( domain, in[i], &out[i], max_bands ) )
return( -1 );
if( interpretation != VIPS_INTERPRETATION_ERROR )
out[i]->Type = interpretation;
}
return( 0 );
}