繁体   English   中英

如何在 Python 中使用 plt.imshow(data) 保存图像之前打印出 16 位数据?

[英]How to print out the 16bit data before saving an image with plt.imshow(data) in Python?

from PIL import Image
from pylab import *
from numpy import NaN
import numpy as np
import matplotlib.pyplot as plt

def julia(C):
    X = arange(-1.5, 1.5, 0.005)
    Y = arange(-1.5, 1.5, 0.005)
    M = zeros((len(Y), len(X)))
    plt.axis('off')

    for x_iter, x in enumerate(X):
        for y_iter, y in enumerate(Y):
            z = x + 1j * y
            pixel = NaN
            for n in range(1, 4096):
                z = z**2 + C
                if abs(z) > 2:
                    pixel = n
                    break

            M[y_iter, x_iter] = pixel

    # (Please help! here I want to print the calculated matrix elements out to check the actual data  values, but how to write out this piece of code?!)

    plt.imshow(M, cmap = cm.cubehelix, extent = (X.min(), X.max(), Y.min(), Y.max()))
    plt.savefig('julia.tiff')

我想打印计算出的矩阵元素来检查实际的数据值,但是如何写出这段代码呢?! 请帮帮我!!

您可以通过print("Calculated Matrix: ",M) M

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM