openslide_read_region returns no picture data

Jan Harkes jaharkes at cs.cmu.edu
Fri Dec 10 11:02:31 EST 2010


On 12/10/2010 02:57 AM, Stefan König wrote:
> here is a part of my sample script to play bit arround with openslide,
> before i use this productive:
>
> 	openslide_read_region(slideObject, dst, 0, 0, 1, *width, *height);
> 	
> 	if(openslide_get_error(slideObject))
> 		std::cout<<  openslide_get_error(slideObject)<<  std::endl;
>
> 	argb8c_view_t gil = boost::gil::interleaved_view(*width, *height,
> (const argb8c_pixel_t*) (dst), (*width)*4);
>
> 	rgb8_image_t exp(*width,*height);
> 	copy_and_convert_pixels(gil, view(exp));
>
> 	jpeg_write_view("C:\\readRegionTest.jpg", view(exp));

I don't know what width and height are set to, but it may be that you 
are clipping some area in the top-left corner of the whole slide image 
where there is no scanned data. In that case the openslide library will 
set the aRGB values all to 0 making the returned region 'transparent 
black'. But as jpeg doesn't support an alpha channel you probably are 
stripping out the transparency resulting in an all black image.

To avoid the black background you would have to composite with the value 
of the openslide.background-color property before stripping the alpha 
channel. This property is pretty new, it was added in version 3.2.3.

Jan


More information about the openslide-users mailing list