We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bcc0b43 commit fc68f53Copy full SHA for fc68f53
src/anomalib/utils/visualization/image.py
@@ -326,7 +326,8 @@ def generate(self) -> np.ndarray:
326
axis.title.set_text(image_dict["title"])
327
self.figure.canvas.draw()
328
# convert canvas to numpy array to prepare for visualization with opencv
329
- img = np.frombuffer(self.figure.canvas.tostring_rgb(), dtype=np.uint8)
330
- img = img.reshape(self.figure.canvas.get_width_height()[::-1] + (3,))
+ img = np.frombuffer(self.figure.canvas.buffer_rgba(), dtype=np.uint8)
+ img = img.reshape(self.figure.canvas.get_width_height()[::-1] + (4,)) # RGBA has 4 channels
331
+ img = cv2.cvtColor(img, cv2.COLOR_RGBA2RGB)
332
plt.close(self.figure)
333
return img
0 commit comments