how can i change a grayscale pixel value by a colored value given the value of the pixel not the coordiante
<p>Hello i want to change a grayscale pixel value by a colored value given the value of the pixel not by the coordiante. 
I know how to do it given the coordiante:</p>

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

<p>But how to do it in values like I[im == 10] = [1, 0 ,0]
doesn't work.</p>

<p>I suggest this, although it might be dirty :</p>

<pre><code>while [10,10,10] in I:
    I[I.index([10,10,10])] = [1,0,0]
</code></pre>

python image image-processing grayscale