1

I am quite new to Python and PyCharm. I am using PyCharm for coding now.

In MATLAB whenever I load an image or data I can easily see my image data (i.e. the values of the pixel intensities) or whenever I load a file I can just see the detail of the file in my workspace.

Can any one tell me if there is anyway to do such a thing in PyCharm?

To explain more: When I run something in MATLAB I will have a work space that shows all my variables etc.

workspace from MATLAB

Now assume this is my Python code:

from PIL import Image
from logistic_sgd import load_data
Img = Image.open("fruits.jpg")

Is there anyway that I see the value for my Img and load_data?

Alex
  • 1,194
  • 1
  • 12
  • 20

1 Answers1

0

Probably the simplest way to do this within PyCharm would be to use the integrated Python Console. You can open it via "Tools" -> "Python Console". Then, if you want to view the pixel data, you could use this technique. For example:

from PIL import Image
Img = Image.open("fruits.jpg")
pixels = list(Img.getdata())
width, height = Img.size
pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)]

Now you can view pixels (R,G,B) values in the pixels matrix. For example, via pixels[0][0]. I know this doesn't provide as clear a view as the simple data view that you get in a MATLAB workspace but you can use it to examine the pixel data.

You can also look into using a jupyter notebook. Load your image there and examine any pixel data you are interested in.

Community
  • 1
  • 1
Paul
  • 5,473
  • 1
  • 30
  • 37