Returns: ndarray: the visualized image of shape (H, W, 3) (RGB) in uint8 type. The shape is scaled w.r.t the input image using the given `scale` argument.
(self)
| 289 | self.fig.savefig(filepath) |
| 290 | |
| 291 | def get_image(self): |
| 292 | """ |
| 293 | Returns: |
| 294 | ndarray: |
| 295 | the visualized image of shape (H, W, 3) (RGB) in uint8 type. |
| 296 | The shape is scaled w.r.t the input image using the given `scale` argument. |
| 297 | """ |
| 298 | canvas = self.canvas |
| 299 | s, (width, height) = canvas.print_to_buffer() |
| 300 | # buf = io.BytesIO() # works for cairo backend |
| 301 | # canvas.print_rgba(buf) |
| 302 | # width, height = self.width, self.height |
| 303 | # s = buf.getvalue() |
| 304 | |
| 305 | buffer = np.frombuffer(s, dtype="uint8") |
| 306 | |
| 307 | img_rgba = buffer.reshape(height, width, 4) |
| 308 | rgb, alpha = np.split(img_rgba, [3], axis=2) |
| 309 | return rgb.astype("uint8") |
| 310 | |
| 311 | |
| 312 | class Visualizer: |
no outgoing calls