将像素值显示为图像 [英] Display pixels values as an image

查看:232
本文介绍了将像素值显示为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个 1280 &次; 960 .TIF 格式图片。我提取了 1.200.000 像素的所有像素。

So I have a 1280 × 960 .TIF format image. I have extracted all pixels which is 1.200.000 pixels.

之后,我使用图像上的每个像素进行了一些计算,假设:

After that, I have done some calculations using each pixel on the image, let's say :

result = each_pixel * some calculation

结果列表也有1.200.000值。

The result list has also 1.200.000 values.

现在我要做的是显示两个不同的图像,第一个是原始像素值,表示原始图像,第二个是 result list,表示为原始图像的完全相同的x和y坐标显示的每个像素计算的结果。

Now what I am trying to do is to display two different images, the first with the original pixel values which means the original image, the second one with the result list, which means the result calculated for each pixel displayed in the exact same x and y coordinates of the original image.

我该怎么做?我想我们可以用像colormap这样的东西来做,但我不确定。

How can I do that? I suppose that we can do it with something like the colormap but I am not sure.

推荐答案

matplotlib 这样做的方法是:

import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np

plt.imsave('filename.png', np.array(result).reshape(1280,960), cmap=cm.gray)
plt.imshow(np.array(result).reshape(1280,960))

注意:你也可以使用 glumpy

Note: You could also use glumpy

这篇关于将像素值显示为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆