I’m using Python with Matplotlib for drawing.
I have two matrices (images in levels of gray) like this:
x = np.array([[0,1,0], [1,0,1]])
y = np.array([[0,0.4,0], [1,0,1]])
I want to plot a new image z which show the differences (as let’s say green points) between x and y and leave the other points in scale of grays. So, in the previous example if 1 is black and 0 is white, z should be an identical image with a green point in correspondence to the difference between x and y (in this case 0.4).
The purpose of this is to animate the k-means algorithm execution in the handwritten data images to watch how the algorithm is working.
I hope this is clear, sorry for my English.
The simplest solution consists in calculating the RGBA colors of your input data first, manipulating it so as to set the values that differ to your special color (green), and then plotting with a simple
imshow()the modified RGBA array. Here is how this can be done:The data points that differ between arrays

xandyare now in green:If you want to overlay your green points on an image previously displayed, you can do something similar and set the alpha channel to 0 where you don’t want to modify your original image: