Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View numpy array as image while debugging in PyCharm?

Is it possible to view numpy array as image while debugging in PyCharm?

I tried to enter

PIL.Image.fromarray(my_data, 'RGB').show()

into watches, but got

PIL is not defined

error. This is probably because PIL was not imported in current module.

Any other way appreciated. May be can write my own viewer or something?

like image 465
Dims Avatar asked Aug 16 '17 14:08

Dims


People also ask

Can Numpy array store images?

Images are an easier way to represent the working model. In Machine Learning, Python uses the image data in the format of Height, Width, Channel format. i.e. Images are converted into Numpy Array in Height, Width, Channel format.

How do I trace a Python program in PyCharm?

Press the Autoscroll to Trace toggle button on the toolbar. After that, on clicking a node in the Events pane, PyCharm shows its call stack in the Event Stack pane aqnd opens the corresponding trace file in the editor.


2 Answers

I've just created OpenCV Image Viewer Plugin, which displays image while debugging just on click. You can install it to any JetBrains IDE, which support Python (directly or via plugin).

https://plugins.jetbrains.com/plugin/14371-opencv-image-viewer

enter image description here

like image 53
dragon7 Avatar answered Oct 13 '22 07:10

dragon7


I was able to import packages with semicolon, and was able to show image with expression like below:

import matplotlib; matplotlib.pyplot.imshow(mydata)
like image 34
Dims Avatar answered Oct 13 '22 06:10

Dims