简体   繁体   中英

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')

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

You can just print M by print("Calculated Matrix: ",M)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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