我希望这是一个非常直截了当的问题。我正在处理从FITS文件读入的一些图像到numpy数组中。我想做一个RGB图像。问题是,当我制作RGB图像时,似乎会出现这种“白色薄雾”。或者,我知道在这张图片中黑色的区域应该是黑色的,但是它们看起来是灰色的。G图像中的果岭非常漂亮。整个图像看起来像是有白色的薄雾或雾。我想也许是设置阿尔法的问题?注:将RBGA中的A设置为0和255对问题没有帮助。在
这是一个图像示例——我会展示它,除非我没有足够的声誉点数。不幸的是,在这种情况下,一张照片抵得上1000个字。。。在
下面是我用来处理图像的代码:
testrgb = np.zeros([512,512,4])
#
# converting read in image to float
tmpr = asi1r.astype('float')
tmpg = asi1g.astype('float')
tmpb = asi1b.astype('float')
#http://akash0x53.github.io/blog/2013/04/29/normalization/ pretty obvious
tmptotal = tmpr+tmpg+tmpb
R = tmpr/tmptotal
G = tmpg/tmptotal
B = tmpb/tmptotal
# eliminate the nans in the division
R[np.isnan(R) == True] = 0.
G[np.isnan(G) == True] = 0.
B[np.isnan(B) == True] = 0.
testrgb[:,:,0] = R*255.
testrgb[:,:,1] = G*255. #asi1g.astype('float')
testrgb[:,:,2] = B*255. #asi1b.astype('float')
testrgb[:,:,3] = 255.
testrgb = testrgb.astype('uint8')
f = plt.figure(figsize=(4,4), dpi=300)
plt.imshow(testrgb,cmap='jet',vmin=0,vmax=200)
plt.colorbar()
plt.show()
f.savefig('test.png')
plt.close('all')
任何帮助都将不胜感激。非常感谢。在
这似乎不是matplotlib的问题。从你的评论看来,正常化的确是错误的。尝试以下操作:
vmax
和vmin
设置不适用于RGB图像。在相关问题 更多 >
编程相关推荐