image.get_pixel

Hello,
I want to “print” the gray scale magnitude for pixel (7,9) to the serial terminal. The line “gs=—” returns a syntax error.
My code below does not work.

import sensor, image, time

sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to GRAYSCALE.
sensor.set_framesize(sensor.VGA)    # Set frame size to QVGA (640x480)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.

img = sensor.snapshot()             # Take a picture and return the image.
gs = in img.(image.get_pixel(7,9))  # Read pixel value of returned image.
print(gs)                           # print pixel value to the serial terminal

You just need to to do:

print(img.get_pixel(7, 9))

Please use the code tags when posting code to improve readability.

What is a “code Tag” ?

There’s a button that says “code” when you are submitting replies here. You click that to insert code tags into the reply which will keep any code you post formatted.