week 11 image filtering Flashcards
how do you import the image altering module?
from PIL import Image
how do you open an image?
img = Image.open(filename + ‘.jpg’)
how do you convert image to RGB?
img = Image.open(filename + ‘.jpg’).convert(‘RGB’)
width of an image?
img.width
height of an image?
img.height
how do you access each pixel of a image
two for loops, one for rows and one for columns
how do you retrieve RGB for a pixel?
r, g, b = img.getpixel((col,row))
how do you reinsert the altered pixel
img.putpixel((col, row), (r, g, b))
how do you save an image?
img.save(‘filename’)
how are images stored
in a 2d matrix of values
pixel
individual elements that compile to the image
in a grayscale image, 255 is…
the whitest
in grayscale image, 0 is…
the darkest
RGB
3 values for red, green, and blue that comprise colors
RBG(0, 0, 0)
black