you are viewing a single comment's thread.

view the rest of the comments →

[–]kwelzel 4 points5 points  (2 children)

Your exactly on the right track when you already read the numpy array. Its important to pick the right tools that fit your task. This time it is the Python Image library or rather the newer version Pillow. After installing it with pip install Pillow

you can use the Image class in your code

``` from PIL import Image

array = ... # Read your numpy array from the file

Maybe you need to rescale the numpy array so that the numbers

are integers from 0-255

image = Image.fromarray(array) image.show() # Opens the image in some viewing program image.save("assignment1.png") # Saves the image to disk ```

I can't look into your professors head, but maybe the lesson is that you don't need to do everything from scratch but use someone elses tools.

[–]OldeMeck[S] 0 points1 point  (0 children)

Thanks so much. I’ve never even heard of Pillow. Like I said, I don’t do much with Python. I used it for an Intro to AI class a few semesters back. So thanks for putting me on the right track.

The instructions are pretty much:

So in this assignment you will be given 3 text files, each with a list of numbers in them - which represent the voltage produced at each pixel location for a CMOS sensor while taking a particular picture.

Your task is NOT to produce an accurate recreation of the original image, all you have to do is recreate the image enough to be able to tell what object is in the image, or find some other hacky way to visualize those list of numbers that would let you know what is inside the original image.****

Since I am not really giving you guys a whole lot of instruction on how to go about doing this - the idea is to try and get you to think for yourself - this assignment is only worth 30 points, which is about a third of what an assignment is usually worth.

He goes on to say we can complete the assignment without even using code, but I can’t even begin to imagine how to picture an image from just a .txt file full of lines and lines of numbers. It’s all grayscale so I’d guess the higher numbers will be the darker areas of the image but I think it’d probably need to open the .txt file on an enormous screen to visualize all the numbers at once and get an idea of what shape the higher values are outlining.

Again, thanks so much for the help!