我正在开发matlab,但我注意到当原始图像中有灰色时,我加载的图像变成了黑白.我决定在新文件上使用imshow判断图像,但它确实使它变成了黑白的.我的代码很简单:
image_path = 'no.png';
img = imread(image_path);
imshow(img);
axis off;
然后我试图将其变成灰度级,但问题没有解决.
然后我try 使用Python来显示图像,它正确地显示了图像.
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
def show_image(image_path):
img = mpimg.imread(image_path)
plt.imshow(img)
plt.axis('off')
plt.show()
# Example usage
image_path = "no.png"
show_image(image_path)
我不知道怎么了. 这是原始图像:
这是matlab显示的图像:
这是Python显示的图像: