Home > Software engineering >  matrices comparisons
matrices comparisons

Time:11-04

I'am trying to deal with satellites pictures using python. To summarize I have two big matrices (3000rows - 16 columns) that show satellites informations with value between [0-100]. I would like that each matrice is represent with a specific color.

here is what I do:


plt.imshow(viz, cmap='Blues',vmax=100,aspect='auto')
plt.imshow(viz1, cmap='Reds',vmax=100,aspect='auto')
plt.show()

with viz and viz1 looking like :

[(100,0,100,45 ...
  ..  .. .. ..  ..
  0 , 23 , 65 , ...)]

[EDIT] my two matrices are satellite pictures. One is the morning the other is the evening. The purpose is to spot the differences

[EDIT] the thing is that sometimes on viz I would have a 0 value and if I substract with wiz1 it will be negative number. I tried the absolute difference but then I loose the informations of the numbe for example i would like to see the value that didnt change from viz 1 in red and viz blue and the value that changed in Orange

CodePudding user response:

If the purpose is to spot the differences between the two images why not use imshow to plot the result of the subtraction of the two matrices:

mat_diff=viz-viz1
plt.imshow(mat_diff,aspect='auto')

And if you are interested in the absolute difference:

mat_abs_diff=abs(viz-viz1)
plt.imshow(mat_abs_diff,aspect='auto')

CodePudding user response:

Giving this another try. Something you could do is to use the alpha argument from your imshow function and use it to see the two images superimposed. In the code below I plot two arrays. The first one is the identity matrix and the second one is the fliplr version of the identity matrix (opposite diagonal). On top of that, I set the element mat_2[0,0]=1 to show what it looks like when the two arrays overlap. Here what this looks like on a toy example:

import numpy as np
import matplotlib.pyplot as plt

N_dim=10
#Creating the two images

#mat_1 is the identity matrix
mat_1=np.diag(N_dim*[1])

#mat_2 is the fliplr version of mat_1 (opposite diagonal)
mat_2=np.diag(N_dim*[1])

#And to create artificial overlap between mat_1 and mat_2, I set the first element [0,0] of mat_2 equal to 1
mat_2=np.fliplr(mat_2)
mat_2[0,0]=1

#imshow with alpha=0.5 to see both images
plt.imshow(mat_1,cmap='Reds',aspect='auto',alpha=0.5)
plt.imshow(mat_2,cmap='Blues',aspect='auto',alpha=0.5)
plt.show()

And the output gives:

enter image description here

The first array appears red, the second blue and the mixture purple.

  • Related