converted image appears black vertical stripes
Operating system
Ubuntu 22.04.2 LTS (GNU/Linux 5.19.0-32-generic x86_64)
Platform
GNU/Linux 5.19.0-32-generic x86_64
OpenSlide Python version
1.4.1
OpenSlide version
4.0.0
Slide format
SVS
Issue details
I use openslide to convert my slice SVS file to PNG file, but the converted image appears black vertical stripes.
Here is my code: `def tif_to_png_with_openslide2(tif_image_path, png_output_path): try: # 使用 OpenSlide 打开大文件 slide = openslide.OpenSlide(tif_image_path) for key, value in slide.properties.items(): print(key, value) slide_data = slide.read_region((0, 0), 1, slide.level_dimensions[1]) slide_data = np.array(slide_data) r,g,b,a = cv2.split(slide_data) slide_data = cv2.merge([r,g,b]) cv2.imwrite(png_output_path, slide_data)
print(f"Successfully converted {tif_image_path} to {png_output_path}")
except Exception as e:
print(f"Error converting TIFF to PNG: {e}")
this is slide.properties:aperio.AppMag 40
aperio.MPP 0.253910
openslide.associated.thumbnail.height 543
openslide.associated.thumbnail.width 1204
openslide.comment Aperio Image Format
154112x69600 [0,0 154112x69600] (256x256) JPEG/RGB Q=60|AppMag = 40|MPP = 0.253910
openslide.level-count 2
openslide.level[0].downsample 1
openslide.level[0].height 69600
openslide.level[0].tile-height 256
openslide.level[0].tile-width 256
openslide.level[0].width 154112
openslide.level[1].downsample 8
openslide.level[1].height 8700
openslide.level[1].tile-height 256
openslide.level[1].tile-width 256
openslide.level[1].width 19264
openslide.mpp-x 0.25391000000000002
openslide.mpp-y 0.25391000000000002
openslide.objective-power 40
openslide.vendor aperio
tiff.Artist KFBIO
tiff.ImageDescription Aperio Image Format
154112x69600 [0,0 154112x69600] (256x256) JPEG/RGB Q=60|AppMag = 40|MPP = 0.253910
tiff.ResolutionUnit inch`
this is my code .i try to two way to finish: `def tif_to_png_with_openslide2(tif_image_path, png_output_path): try: # 使用 OpenSlide 打开大文件 slide = openslide.OpenSlide(tif_image_path) for key, value in slide.properties.items(): print(key, value) slide_data = slide.read_region((0, 0), 1, slide.level_dimensions[1]) slide_data = np.array(slide_data) r,g,b,a = cv2.split(slide_data) slide_data = cv2.merge([r,g,b]) cv2.imwrite(png_output_path, slide_data)
print(f"Successfully converted {tif_image_path} to {png_output_path}")
except Exception as e:
print(f"Error converting TIFF to PNG: {e}")`
code 2: `def tif_to_png_with_openslide(tif_image_path, png_output_path): try: # 使用 OpenSlide 打开大文件 slide = openslide.OpenSlide(tif_image_path)
# 指定缩略图的目标大小
thumbnail_size = (2048, 2048)
# 获取缩略图
thumbnail = slide.get_thumbnail(thumbnail_size)
# 将图像保存为 PNG 格式
thumbnail.save(png_output_path)
print(f"Successfully converted {tif_image_path} to {png_output_path}")
except Exception as e:
print(f"Error converting TIFF to PNG: {e}")`
Your SVS file probably omits image tiles for empty portions of the slide. OpenSlide renders missing image tiles as transparent pixels, which you're seeing as black pixels because you're discarding the returned alpha channel.
The stripes are surprising though. Could you upload a sample slide that shows this behavior?
Your SVS file probably omits image tiles for empty portions of the slide. OpenSlide renders missing image tiles as transparent pixels, which you're seeing as black pixels because you're discarding the returned alpha channel.
The stripes are surprising though. Could you upload a sample slide that shows this behavior?
Thank you very much. I have uploaded my SVS file。 ps: google account:[email protected] email:[email protected] file name: N006802-1-2.svs