Thursday, January 22, 2015

How to apply image effects to pictures on Raspberry Pi

http://xmodulo.com/apply-image-effects-pictures-raspberrypi.html

Like a common pocket camera which has a built-in function to add various effects on captured photos, Raspberry Pi camera board ("raspi cam") can actually do the same. With the help of raspistill camera control options, we can add the image effects function like we have in a pocket camera.

There are three comman-line applications which can be utilized for taking videos or pictures with raspi cam, and one of them is the raspistill application. The raspistill
tool offers various camera control options such as sharpness, contrast,
brightness, saturation, ISO, exposure, automatic white balance (AWB),
image effects.

In this article I will show how to apply exposure, AWB, and other image effects with raspistill
while capturing pictures using raspi cam. To automate the process, I
wrote a simple Python script which takes pictures and automatically
applies a series of image effects to the pictures. The raspi cam
documentation describes available types of the exposure, AWB, and image
effects. In total, the raspi cam offers 16 types of image effects, 12
types of exposure, and 10 types of AWB values.

The Python script operates as follows. First, create three array/list
variable for the exposure, AWB and image effects. In the example, we
use 2 types of exposure, 3 types of AWB, and 13 types of image effects
values. Then make nested loops for applying the value of the three
variables that we have. Inside the nested loop, execute the raspistill
application. We specify (1) the output filename; (2) exposure value;
(3) AWB value; (4) image effect value; (5) the time to take a photo,
which is set to 1 second; and (6) the size of the photo, which is set to
640x480px. This Python script will create 78 different versions of a
captured photo with a combination of 2 types of exposure, 3 types of
AWB, and 13 types of image effects.

To execute the Python script, simply type:

$ python name_of_this_script.py

Here is the first round of the sample result.

Bonus

For those who are more interested, there is another way to access and control the raspi cam besides raspistill. Picamera
a pure Python interface which provides APIs for accessing and
controlling raspi cam, so that one can build a complex program for
utilizing raspi cam according to their needs. If you are skilled at
Python, picamera is a good feature-complete interface for implementing
your raspi cam project. The picamera interface is included by default in
the recent image of Raspbian. If your Raspberry Pi operating system is not new or not Raspbian, you can install it on your system as follows.