Spaces:
Runtime error
Runtime error
Correction
Browse files
app.py
CHANGED
|
@@ -46,17 +46,11 @@ def histogramme(image):
|
|
| 46 |
La fonction fait la différence entre les images à un canal et celles à trois
|
| 47 |
"""
|
| 48 |
img_array = np.array(image)
|
|
|
|
| 49 |
fig, axis = plt.subplots(figsize=(8, 4))
|
| 50 |
-
axis.set_title("Histogramme")
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
histo = cv2.calcHist([img_array], [0], None, [256], [0, 256])
|
| 54 |
-
axis.plot(histo, color='black')
|
| 55 |
-
else:
|
| 56 |
-
rgbcolors = ["blue", "green", "red"]
|
| 57 |
-
for i, col in enumerate(rgbcolors):
|
| 58 |
-
histo = cv2.calcHist([img_array], [i], None, [256], [0, 256])
|
| 59 |
-
axis.plot(histo, color=col)
|
| 60 |
|
| 61 |
fig.canvas.draw()
|
| 62 |
data = np.frombuffer(fig.canvas.buffer_rgba(), dtype=np.uint8)
|
|
|
|
| 46 |
La fonction fait la différence entre les images à un canal et celles à trois
|
| 47 |
"""
|
| 48 |
img_array = np.array(image)
|
| 49 |
+
gray_image = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
|
| 50 |
fig, axis = plt.subplots(figsize=(8, 4))
|
| 51 |
+
axis.set_title("Histogramme des niveaux de gris")
|
| 52 |
+
histo = cv2.calcHist([img_array], [0], None, [256], [0, 256])
|
| 53 |
+
axis.plot(histo, color='black')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
fig.canvas.draw()
|
| 56 |
data = np.frombuffer(fig.canvas.buffer_rgba(), dtype=np.uint8)
|