<tfoot id='EbBPf'></tfoot>
<i id='EbBPf'><tr id='EbBPf'><dt id='EbBPf'><q id='EbBPf'><span id='EbBPf'><b id='EbBPf'><form id='EbBPf'><ins id='EbBPf'></ins><ul id='EbBPf'></ul><sub id='EbBPf'></sub></form><legend id='EbBPf'></legend><bdo id='EbBPf'><pre id='EbBPf'><center id='EbBPf'></center></pre></bdo></b><th id='EbBPf'></th></span></q></dt></tr></i><div id='EbBPf'><tfoot id='EbBPf'></tfoot><dl id='EbBPf'><fieldset id='EbBPf'></fieldset></dl></div>

  • <legend id='EbBPf'><style id='EbBPf'><dir id='EbBPf'><q id='EbBPf'></q></dir></style></legend>
  • <small id='EbBPf'></small><noframes id='EbBPf'>

          <bdo id='EbBPf'></bdo><ul id='EbBPf'></ul>
      1. 在 Python 中将 3D 数组保存到一堆 2D 图像中

        Save 3D array into a stack of 2D images in Python(在 Python 中将 3D 数组保存到一堆 2D 图像中)
        <legend id='2lhGu'><style id='2lhGu'><dir id='2lhGu'><q id='2lhGu'></q></dir></style></legend>

            <bdo id='2lhGu'></bdo><ul id='2lhGu'></ul>

                <tbody id='2lhGu'></tbody>

              <small id='2lhGu'></small><noframes id='2lhGu'>

              <tfoot id='2lhGu'></tfoot>

              <i id='2lhGu'><tr id='2lhGu'><dt id='2lhGu'><q id='2lhGu'><span id='2lhGu'><b id='2lhGu'><form id='2lhGu'><ins id='2lhGu'></ins><ul id='2lhGu'></ul><sub id='2lhGu'></sub></form><legend id='2lhGu'></legend><bdo id='2lhGu'><pre id='2lhGu'><center id='2lhGu'></center></pre></bdo></b><th id='2lhGu'></th></span></q></dt></tr></i><div id='2lhGu'><tfoot id='2lhGu'></tfoot><dl id='2lhGu'><fieldset id='2lhGu'></fieldset></dl></div>
                • 本文介绍了在 Python 中将 3D 数组保存到一堆 2D 图像中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我制作了一个由数字(0~4)组成的 3D 数组.我想要的是将 3D 数组保存为 2D 图像堆栈(如果可能,保存 *.tiff 文件).我该怎么办?

                  I made a 3D array, which consists of numbers(0~4). What I want is to save 3D array as a stack of 2D images(if possible, save *.tiff file). What am I supposed to do?

                  import numpy as np
                  
                  a = np.random.randint(0,5, size=(100,100,100))
                  a = a.astype('int8')
                  

                  推荐答案

                  这应该可行.我还没有测试过它,但是我已经使用这种方法将彩色图像分成了 RGB 切片,并且它应该在这里以几乎相同的方式工作,假设您不想先对这些像素值做任何事情.(它们将非常接近图像中的相同颜色).

                  This should work. I haven't tested it but I have separated color images into RGB slices using this method and it should work pretty much the same way here, assuming you don't want to do anything with those pixel values first. (They will be very close to the same color in an image).

                  import imageio
                  import numpy as np
                  
                  a = np.random.randint(0,5, size=(100,100,100))
                  a = a.astype('int8')
                  for i in range(100):
                      newimage = a[:, :, i]
                      imageio.imwrite("path/to/image%d.tiff" %i, newimage)
                  

                  这篇关于在 Python 中将 3D 数组保存到一堆 2D 图像中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                • <legend id='5HmHh'><style id='5HmHh'><dir id='5HmHh'><q id='5HmHh'></q></dir></style></legend>

                  <small id='5HmHh'></small><noframes id='5HmHh'>

                • <tfoot id='5HmHh'></tfoot>

                  • <bdo id='5HmHh'></bdo><ul id='5HmHh'></ul>
                    <i id='5HmHh'><tr id='5HmHh'><dt id='5HmHh'><q id='5HmHh'><span id='5HmHh'><b id='5HmHh'><form id='5HmHh'><ins id='5HmHh'></ins><ul id='5HmHh'></ul><sub id='5HmHh'></sub></form><legend id='5HmHh'></legend><bdo id='5HmHh'><pre id='5HmHh'><center id='5HmHh'></center></pre></bdo></b><th id='5HmHh'></th></span></q></dt></tr></i><div id='5HmHh'><tfoot id='5HmHh'></tfoot><dl id='5HmHh'><fieldset id='5HmHh'></fieldset></dl></div>
                          <tbody id='5HmHh'></tbody>