look for tile-width and tile-height properties
get tile geo from openslide
This commit is contained in:
parent
d0b1740fd1
commit
ab1d4ac6b8
@ -2,6 +2,7 @@
|
|||||||
- dzsave can write zoomify and google maps layout as well
|
- dzsave can write zoomify and google maps layout as well
|
||||||
- openslide2vips now opens the input once for each thread
|
- openslide2vips now opens the input once for each thread
|
||||||
- tilecache supports threaded access
|
- tilecache supports threaded access
|
||||||
|
- openslide2vips gets underlying tile size from openslide
|
||||||
|
|
||||||
2/10/12 started 7.30.4
|
2/10/12 started 7.30.4
|
||||||
- remove options from format string in .dzi (thanks Martin)
|
- remove options from format string in .dzi (thanks Martin)
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
* 4/10/12
|
* 4/10/12
|
||||||
* - open the image once for each thread, so we get some parallelism on
|
* - open the image once for each thread, so we get some parallelism on
|
||||||
* decode
|
* decode
|
||||||
|
* 11/10/12
|
||||||
|
* - look for tile-width and tile-height properties
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -82,15 +84,6 @@
|
|||||||
|
|
||||||
#include "openslide2vips.h"
|
#include "openslide2vips.h"
|
||||||
|
|
||||||
/* We run our own tile cache. The OpenSlide one can't always keep enough for a
|
|
||||||
* complete lines of pixels.
|
|
||||||
*
|
|
||||||
* These numbers need to align with the tiles used in the underlying openslide
|
|
||||||
* image. We need to add something to openslide to output this data.
|
|
||||||
*/
|
|
||||||
#define TILE_WIDTH (256)
|
|
||||||
#define TILE_HEIGHT (256)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
openslide_t *osr;
|
openslide_t *osr;
|
||||||
char *filename;
|
char *filename;
|
||||||
@ -102,6 +95,11 @@ typedef struct {
|
|||||||
int32_t level;
|
int32_t level;
|
||||||
double downsample;
|
double downsample;
|
||||||
uint32_t bg;
|
uint32_t bg;
|
||||||
|
|
||||||
|
/* Try to get these from openslide properties.
|
||||||
|
*/
|
||||||
|
int tile_width;
|
||||||
|
int tile_height;
|
||||||
} ReadSlide;
|
} ReadSlide;
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -183,6 +181,11 @@ readslide_new( const char *filename, VipsImage *out,
|
|||||||
rslide->level = level;
|
rslide->level = level;
|
||||||
rslide->associated = g_strdup( associated );
|
rslide->associated = g_strdup( associated );
|
||||||
|
|
||||||
|
/* Non-crazy defaults, override below if we can.
|
||||||
|
*/
|
||||||
|
rslide->tile_width = 256;
|
||||||
|
rslide->tile_height = 256;
|
||||||
|
|
||||||
rslide->osr = openslide_open( rslide->filename );
|
rslide->osr = openslide_open( rslide->filename );
|
||||||
if( rslide->osr == NULL ) {
|
if( rslide->osr == NULL ) {
|
||||||
vips_error( "openslide2vips",
|
vips_error( "openslide2vips",
|
||||||
@ -216,12 +219,29 @@ readslide_new( const char *filename, VipsImage *out,
|
|||||||
vips_demand_hint( out, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
vips_demand_hint( out, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
char buf[256];
|
||||||
|
const char *value;
|
||||||
|
|
||||||
openslide_get_level_dimensions( rslide->osr,
|
openslide_get_level_dimensions( rslide->osr,
|
||||||
level, &w, &h );
|
level, &w, &h );
|
||||||
rslide->downsample = openslide_get_level_downsample(
|
rslide->downsample = openslide_get_level_downsample(
|
||||||
rslide->osr, level );
|
rslide->osr, level );
|
||||||
vips_image_set_int( out, "slide-level", level );
|
vips_image_set_int( out, "slide-level", level );
|
||||||
vips_demand_hint( out, VIPS_DEMAND_STYLE_SMALLTILE, NULL );
|
vips_demand_hint( out, VIPS_DEMAND_STYLE_SMALLTILE, NULL );
|
||||||
|
|
||||||
|
/* Try to get tile width/height. An undocumented, experimental
|
||||||
|
* feature.
|
||||||
|
*/
|
||||||
|
vips_snprintf( buf, 256,
|
||||||
|
"openslide.level[%d].tile-width", level );
|
||||||
|
if( (value = openslide_get_property_value( rslide->osr, buf )) )
|
||||||
|
rslide->tile_width = atoi( value );
|
||||||
|
vips_snprintf( buf, 256,
|
||||||
|
"openslide.level[%d].tile-height", level );
|
||||||
|
if( (value = openslide_get_property_value( rslide->osr, buf )) )
|
||||||
|
rslide->tile_height = atoi( value );
|
||||||
|
if( value )
|
||||||
|
VIPS_DEBUG_MSG( "readslide_new: found tile-size\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
rslide->bg = 0xffffff;
|
rslide->bg = 0xffffff;
|
||||||
@ -326,13 +346,13 @@ vips__openslide_generate( VipsRegion *out,
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We're inside a cache, so requests should always be TILE_WIDTH by
|
/* We're inside a cache, so requests should always be
|
||||||
* TILE_HEIGHT pixels and on a tile boundary.
|
* tile_width by tile_height pixels and on a tile boundary.
|
||||||
*/
|
*/
|
||||||
g_assert( (r->left % TILE_WIDTH) == 0 );
|
g_assert( (r->left % rslide->tile_width) == 0 );
|
||||||
g_assert( (r->top % TILE_HEIGHT) == 0 );
|
g_assert( (r->top % rslide->tile_height) == 0 );
|
||||||
g_assert( r->width <= TILE_WIDTH );
|
g_assert( r->width <= rslide->tile_width );
|
||||||
g_assert( r->height <= TILE_HEIGHT );
|
g_assert( r->height <= rslide->tile_height );
|
||||||
|
|
||||||
openslide_read_region( seq->osr,
|
openslide_read_region( seq->osr,
|
||||||
seq->buf,
|
seq->buf,
|
||||||
@ -427,9 +447,10 @@ vips__openslide_read( const char *filename, VipsImage *out, int level )
|
|||||||
* 50%.
|
* 50%.
|
||||||
*/
|
*/
|
||||||
if( vips_tilecache( raw, &t,
|
if( vips_tilecache( raw, &t,
|
||||||
"tile_width", TILE_WIDTH,
|
"tile_width", rslide->tile_width,
|
||||||
"tile_height", TILE_HEIGHT,
|
"tile_height", rslide->tile_height,
|
||||||
"max_tiles", (int) (1.5 * (1 + raw->Xsize / TILE_WIDTH)),
|
"max_tiles",
|
||||||
|
(int) (1.5 * (1 + raw->Xsize / rslide->tile_width)),
|
||||||
"threaded", TRUE,
|
"threaded", TRUE,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
Loading…
Reference in New Issue
Block a user