"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libvips/foreign/fits.c" between
vips-8.10.6.tar.gz and vips-8.11.0.tar.gz

About: VIPS is a free image processing system (see also the GUI nip2).

fits.c  (vips-8.10.6):fits.c  (vips-8.11.0)
skipping to change at line 220 skipping to change at line 220
{ FLOAT_IMG, VIPS_FORMAT_FLOAT, TFLOAT }, { FLOAT_IMG, VIPS_FORMAT_FLOAT, TFLOAT },
{ DOUBLE_IMG, VIPS_FORMAT_DOUBLE, TDOUBLE } { DOUBLE_IMG, VIPS_FORMAT_DOUBLE, TDOUBLE }
}; };
static int static int
vips_fits_get_header( VipsFits *fits, VipsImage *out ) vips_fits_get_header( VipsFits *fits, VipsImage *out )
{ {
int status; int status;
int bitpix; int bitpix;
int width, height, bands, format, type; int width, height, bands;
VipsBandFormat format;
VipsInterpretation interpretation;
int keysexist; int keysexist;
int i; int i;
status = 0; status = 0;
/* Some FITS images have the first HDU for extra metadata ... skip /* Some FITS images have the first HDU for extra metadata ... skip
* forward until we find a header unit we can load as an image. * forward until we find a header unit we can load as an image.
*/ */
for(;;) { for(;;) {
if( fits_get_img_paramll( fits->fptr, if( fits_get_img_paramll( fits->fptr,
skipping to change at line 321 skipping to change at line 323
if( i == VIPS_NUMBER( fits2vips_formats ) ) { if( i == VIPS_NUMBER( fits2vips_formats ) ) {
vips_error( "fits", _( "unsupported bitpix %d\n" ), vips_error( "fits", _( "unsupported bitpix %d\n" ),
bitpix ); bitpix );
return( -1 ); return( -1 );
} }
format = fits2vips_formats[i][1]; format = fits2vips_formats[i][1];
fits->datatype = fits2vips_formats[i][2]; fits->datatype = fits2vips_formats[i][2];
if( bands == 1 ) { if( bands == 1 ) {
if( format == VIPS_FORMAT_USHORT ) if( format == VIPS_FORMAT_USHORT )
type = VIPS_INTERPRETATION_GREY16; interpretation = VIPS_INTERPRETATION_GREY16;
else else
type = VIPS_INTERPRETATION_B_W; interpretation = VIPS_INTERPRETATION_B_W;
} }
else if( bands == 3 ) { else if( bands == 3 ) {
if( format == VIPS_FORMAT_USHORT ) if( format == VIPS_FORMAT_USHORT )
type = VIPS_INTERPRETATION_RGB16; interpretation = VIPS_INTERPRETATION_RGB16;
else else
type = VIPS_INTERPRETATION_sRGB; interpretation = VIPS_INTERPRETATION_sRGB;
} }
else else
type = VIPS_INTERPRETATION_MULTIBAND; interpretation = VIPS_INTERPRETATION_MULTIBAND;
vips_image_pipelinev( out, VIPS_DEMAND_STYLE_SMALLTILE, NULL ); vips_image_pipelinev( out, VIPS_DEMAND_STYLE_SMALLTILE, NULL );
vips_image_init_fields( out, vips_image_init_fields( out,
width, height, bands, width, height, bands,
format, format,
VIPS_CODING_NONE, type, 1.0, 1.0 ); VIPS_CODING_NONE, interpretation, 1.0, 1.0 );
/* Read all keys into meta. /* Read all keys into meta.
*/ */
if( fits_get_hdrspace( fits->fptr, &keysexist, NULL, &status ) ) { if( fits_get_hdrspace( fits->fptr, &keysexist, NULL, &status ) ) {
vips_fits_error( status ); vips_fits_error( status );
return( -1 ); return( -1 );
} }
for( i = 0; i < keysexist; i++ ) { for( i = 0; i < keysexist; i++ ) {
char record[81]; char record[81];
skipping to change at line 520 skipping to change at line 522
* generate. * generate.
*/ */
return( 0 ); return( 0 );
} }
int int
vips__fits_read( const char *filename, VipsImage *out ) vips__fits_read( const char *filename, VipsImage *out )
{ {
VipsImage *t; VipsImage *t;
int n_bands; int bands;
VipsInterpretation interpretation;
VIPS_DEBUG_MSG( "fits2vips: reading \"%s\"\n", filename ); VIPS_DEBUG_MSG( "fits2vips: reading \"%s\"\n", filename );
/* fits is naturally a band-separated format. For single-band images /* fits is naturally a band-separated format. For single-band images
* we can just read out. For many bands we read each band out * we can just read out. For many bands we read each band out
* separately then join them. * separately then join them.
*/ */
t = vips_image_new(); t = vips_image_new();
if( vips__fits_read_header( filename, t ) ) { if( vips__fits_read_header( filename, t ) ) {
g_object_unref( t ); g_object_unref( t );
return( -1 ); return( -1 );
} }
n_bands = t->Bands; bands = t->Bands;
interpretation = t->Type;
g_object_unref( t ); g_object_unref( t );
if( n_bands == 1 ) { if( bands == 1 ) {
if( fits2vips( filename, out, 0 ) ) if( fits2vips( filename, out, 0 ) )
return( -1 ); return( -1 );
} }
else { else {
VipsImage **x; VipsImage **x;
VipsImage **y;
int i; int i;
t = vips_image_new(); t = vips_image_new();
x = (VipsImage **) vips_object_local_array( VIPS_OBJECT( t ), x = (VipsImage **) vips_object_local_array( VIPS_OBJECT( t ),
n_bands + 1 ); bands );
y = (VipsImage **) vips_object_local_array( VIPS_OBJECT( t ),
3 );
for( i = 0; i < n_bands; i++ ) { for( i = 0; i < bands; i++ ) {
x[i] = vips_image_new(); x[i] = vips_image_new();
if( fits2vips( filename, x[i], i ) ) { if( fits2vips( filename, x[i], i ) ) {
g_object_unref( t ); g_object_unref( t );
return( -1 ); return( -1 );
} }
} }
if( vips_bandjoin( x, &x[n_bands], n_bands, NULL ) || if( vips_bandjoin( x, &y[0], bands, NULL ) ||
vips_image_write( x[n_bands], out ) ) { vips_copy( y[0], &y[1],
"interpretation", interpretation,
NULL ) ||
vips_image_write( y[1], out ) ) {
g_object_unref( t ); g_object_unref( t );
return( -1 ); return( -1 );
} }
g_object_unref( t ); g_object_unref( t );
} }
return( 0 ); return( 0 );
} }
 End of changes. 14 change blocks. 
14 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)