简体   繁体   English

如何为使用 python 保存的 tiff 图像设置像素大小,以便在 ImageJ 中将像素高度和宽度设置为特定值?

[英]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 好心地教了我两件事:

  1. 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'))
  2. 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.

相关问题 如何使用Python保存ImageJ Tiff元数据 - How to save ImageJ tiff metadata using Python 如何在Python中设置像素的alpha值 - How to set alpha value of a pixel in Python 计算给定一组图像的所有不同像素值 - Count all different pixel values given a set of images 如何使用python逐像素显示图像? - How can I show an image plotting pixel by pixel using python? 保存的图片Python的红色像素值不正确 - Incorrect red pixel values of saved picture Python 当标记设置为像素时,如何在图例中更改标记大小/比例 - How to change marker size/scale in legend when marker is set to pixel 在pygame中使用set_at时,像素RGB值反转 - Pixel RGB values inverted when using set_at in pygame 如何使用 tkinter 在 tiff 图像上选择矩形区域并提取矩形内的像素值? - How to select rectangle region on tiff image using tkinter and extract pixel values within the rectangle? 使用python,如何预测SVG中文本的像素宽度? - using python, how do I predict the pixel width of text in an SVG? 如何在一组任意像素值(而不是图像数据结构)上使用ICC配置文件执行颜色转换? - How can one perform color transforms with ICC profiles on a set of arbitrary pixel values (not on an image data structure)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM