本文介绍了matplotlib`imshow(interpolation ='nearest')`做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在灰度图像上使用 imshow 函数与 interpolation ='nearest'并获得漂亮的彩色图片结果,看起来它为我做了某种颜色分割,到底发生了什么?

I use imshow function with interpolation='nearest' on a grayscale image and get a nice color picture as a result, looks like it does some sort of color segmentation for me, what exactly is going on there?

我还希望得到类似这样的图像处理,numpy数组上有一些函数,如 interpolate('nearest')在那里?

I would also like to get something like this for image processing, is there some function on numpy arrays like interpolate('nearest') out there?

编辑:请纠正我,如果我错了,它看起来像是简单的像素聚类(簇是相应色彩图的颜色),最近一词表示它采用最近的色彩图颜色(可能在RGB空间中)来决定像素属于哪个簇。

Please correct me if I'm wrong, it looks like it does simple pixel clustering (clusters are colors of the corresponding colormap) and the word 'nearest' says that it takes the nearest colormap color (probably in the RGB space) to decide to which cluster the pixel belongs.

推荐答案

interpolation ='nearest'如果显示分辨率与显示分辨率不同,则只显示图像而不尝试在像素之间进行插值图像分辨率(最常见的情况)。这将产生一个图像,其中像素显示为多个像素的正方形。

interpolation='nearest' simply displays an image without trying to interpolate between pixels if the display resolution is not the same as the image resolution (which is most often the case). It will result an image in which pixels are displayed as a square of multiple pixels.

interpolation ='nearest'并且灰度图像以彩色显示。默认情况下, imshow 使用 jet 色彩映射来显示图像。如果您希望它以灰度显示,请调用 gray()方法选择灰色色彩图。

There is no relation between interpolation='nearest' and the grayscale image being displayed in color. By default imshow uses the jet colormap to display an image. If you want it to be displayed in greyscale, call the gray() method to select the gray colormap.

这篇关于matplotlib`imshow(interpolation ='nearest')`做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 04:06