Physicist Physicist - 6 months ago 39
jQuery Question

how to set the camera in raspberry pi to take black and white image?

Are there any ways to set the camera in raspberry pi to take black and white image?, like using some commands / code in picamera library?

Since I need to compare the relative light intensity of a few different images, I'm worried that the camera will already so some adjustments itself when the object is under different illuminations, so even if I convert the image to black and white later on the object's 'true' black and white image will have been lost.

thanks

edit: basically what I need to do is to capture a few images of an object when the camera position is fixed, but the position of the light source is changed (and so the direction of illumination is changed as well). Then for each point on the image I will need to compare the relative light intensity of the different images. As long as the light intensity, or the 'brightness' of all the images are relative to the same scale, then it's ok, but I'm not sure if this is the case. I'm sure if the camera will adjust something like contrast automatically itself when an image is 'inherently' darker or brighter.

Answer

To get a black and white image (monochrome, grayscale), just configure your camera. Create a "takeashot.py" ( sudo nano takeashot.py ):

import picamera                  # import files

camera = picamera.PiCamera()     # initialize camera
camera.color_effects = (128,128) # turn camera to black and white
camera.capture('image1.jpg')     # take a shot

Execute:

sudo python takeashot.py

That´s it

You can learn more here:

10. API - picamera.camera Module

"to make the image black and white set the value to (128, 128)."