检查matplotlib图形上特定点/像素的颜色

时间:2019-10-14 14:43:27

标签: python matplotlib colors

我正在尝试编写一个程序来检查matplotlib图上的某个点(带有坐标)是否为白色。问题是我找不到与matplotlib匹配的确切语句。我不知道我是否在使用正确的工具,而我一直在互联网上搜索并且找不到解决方案。这是我的代码:

import pylab as pl
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.colors import is_color_like
import numpy as np
from PIL import Image

img = Image.open("C:/Users/User/Desktop/python files/pictures.python/orthogonal_maze_with_20_by_20_cells.png")
img_grey = img.convert('L')
img_array = np.array(img_grey)

start_point_x = 150
start_point_y= 0
start_point_x_co = [start_point_x]
start_point_y_co = [start_point_y]

start_point = plt.plot(start_point_x_co,start_point_y_co,'r-o')

def next_co(start_point_x,start_point_y):
    while True:
        start_point_y-1
        next_point = plt.plot[start_point_x,start_point_y]
        color = next_point.is_color_like('w')
        if color == True:
            plt.plot(start_point_x_co,start_point_y_co,'r-o')
            continue
        else:
            break


pl.imshow(img_array, cmap= cm.Greys_r )
pl.show()

如何检查matplotlib上某个点的颜色? 感谢您的帮助和时间。

0 个答案:

没有答案
相关问题