・ I studied image processing with python in order to play with the raspberry pi and the sensor in combination.
Install Anaconda (python3.5) https://www.continuum.io/downloads
・ All information stored in pixels is one-dimensional ・ Generally, convert from RGB to grayscale with the following formula
Y = 0.299 * R + 0.587 * G + 0.114 * B
・ Y is brightness (represents light intensity)
test.py
#Load a class that represents an image
from PIL import Image
#Open sample image
img = Image.open('sample.png')
#Convert to grayscale
gray_img = img.convert('L')
gray_img.save('sample-gray.png')
Execute with the following command
$ python test.py
test2.py
from PIL import Image
img = Image.open('sample.png')
r, g, b = img.split()
img = Image.merge("RGB", (b,r,g))
img.save('sample-convert.png')
Since I was able to process the image, I would like to do image recognition (corresponding to scale changes) next time.
Recommended Posts