在给定像素值而不是坐标的情况下,如何通过彩色值更改灰度像素值

问题描述 投票:0回答:1

我想在给定像素值而不是坐标的情况下,通过彩色值更改灰度像素值。鉴于坐标,我知道如何做到这一点:

I = np.dstack([im, im, im])
x = 5
y = 5
I[x, y, :] = [1, 0, 0]
plt.imshow(I, interpolation='nearest' )

但是如何在像[im == 10] = [1,0,0]这样的值中这样做是行不通的。

python image image-processing grayscale
1个回答
0
投票

我建议这个,虽然它可能很脏:

while [10,10,10] in I:
    I[I.index([10,10,10])] = [1,0,0]
© www.soinside.com 2019 - 2024. All rights reserved.