[英]How can pixel size be set for tiff images saved using python so that the pixel height and width are set to particular values in ImageJ?
There are numerous means {PIL, opencv, tifffile, et cetera} for creating tiff image files from numpy arrays.从 numpy 数组创建 tiff 图像文件有多种方法 {PIL、opencv、tifffile 等}。 How can pixel size be set for tiff images saved using python so that the pixel height and width have particular values in ImageJ?
如何为使用 python 保存的 tiff 图像设置像素大小,以便像素高度和宽度在 ImageJ 中具有特定值?
When a tiff image is opened in ImageJ, Ctrl+Shift+P opens an image properties window such as:在 ImageJ 中打开 tiff 图像时,Ctrl+Shift+P 会打开一个图像属性窗口,例如:
There are tiff tags that include XResolution, YResolution, ResolutionUnit, PixelXDimension, PixelYDimension, et cetera.有 tiff 标签,包括 XResolution、YResolution、ResolutionUnit、PixelXDimension、PixelYDimension 等。 Which, if any, of these can be used to set a property of the saved image so that ImageJ uses specified Pixel width and height?
哪些(如果有)可用于设置保存图像的属性,以便 ImageJ 使用指定的像素宽度和高度? Which packages enable setting of such tags during the save process?
哪些软件包可以在保存过程中设置此类标签?
Christoph Gohlke, creator of tifffile, kindly taught me two things: tifffile 的创建者 Christoph Gohlke 好心地教了我两件事:
tifffile will set XResolution, YResolution and ResolutionUnit tags if a resolution tuple is passed to tifffile.imsave.如果将分辨率元组传递给 tifffile.imsave,tifffile 将设置 XResolution、YResolution 和 ResolutionUnit 标签。 Building on What is the best way to save image metadata alongside a tif?
在tif 旁边保存图像元数据的最佳方法是什么? from Jenny Folkesson, I added a resolution tuple
来自 Jenny Folkesson,我添加了一个分辨率元组
tifffile.imsave( my_tiff, float64_im.astype('float32'), ijmetadata=ijmetadata, description=description, extratags=extra_tags, resolution=(1/pixel_pitch_in_cm, 1/pixel_pitch_in_cm, 'CENTIMETER'))
ImageJ doesn't readily open tiffs having 64-bit float data. ImageJ 不容易打开具有 64 位浮点数据的 tiff。 The work-around is to cast the image to 'float32' before passing it to tifffile.imsave.
解决方法是在将图像传递给 tifffile.imsave 之前将其转换为“float32”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.