2017-10-07 4 views

Répondre

0

Ceci est de démontrer un peu différent de votre cas que je ne connais pas ses données. Je soupçonne que toutes les valeurs de votre tableau 'O' sont nulles, donc, l'intrigue est apparue comme un volet noir.

import numpy as np 
import matplotlib.pyplot as plt 

fig=plt.figure(figsize=(8, 4)) 

# make up some data for demo purposes 
raw = np.random.randint(10, size=(6,6)) 
# apply some logic operatioin to the data 
O = (raw >= 5) * 1 # get either 0 or 1 in the array 
I = np.random.randint(10, size=(6,6)) # get 0-9 in the array 

# plot each image ... 
# ... side by side 
fig.add_subplot(1, 2, 1) # subplot one 
plt.imshow(I, cmap=plt.cm.gray) 

fig.add_subplot(1, 2, 2) # subplot two 
# my data is OK to use gray colormap (0:black, 1:white) 
plt.imshow(O, cmap=plt.cm.gray) # use appropriate colormap here 
plt.show() 

L'image résultante:

enter image description here

0

Le code de la question fonctionne très bien.

import matplotlib.pyplot as plt 
import numpy as np 

img = plt.imread("https://i.stack.imgur.com/oos05.png")[88:456,82:326] 
t = 0.5 

O = (img >= t) * 1 
I = img 
both = np.hstack((I, O)) 
plt.imshow(both, cmap='gray') 
plt.show() 

enter image description here