Python opencv 伪彩色保存的结果和plt.imshow(blur_heatMap_jet)的结果截然相反 Python opencv如何imshow一张图片

blur_heatMap_jet = cv2.applyColorMap(blur2, 2)

方案1: plt

plt.figure()
plt.imshow(blur_heatMap_jet)
plt.show()

的结果

方案2: cv2的结果

cv2.imwrite(heatMapPath, blur_heatMap_jet)

结论:两者不一样。

---------------------------

Python opencv如何imshow一张图片

# Python program to explain cv2.imshow() method 

# importing cv2 

import cv2


# path

path = r'C:\Users\Rajnish\Desktop\geeksforgeeks.png'

# Reading an image in default mode

image = cv2.imread(path)


# Window name in which image is displayed

window_name = 'image'

# Using cv2.imshow() method 

# Displaying the image 

cv2.imshow(window_name, image)


#waits for user to press any key 

#(this is necessary to avoid Python kernel form crashing)

cv2.waitKey(0)

#closing all open windows 

cv2.destroyAllWindows()

一行命令!  等价于 matlab中imshow(img)

cv2.imshow("window_name", combineImg), cv2.waitKey(0)
posted @ 2022-04-24 14:30  bH1pJ  阅读(44)  评论(0编辑  收藏  举报