In this article we will demonstrate a simple conversion from RGBA to grayscale image using CUDA 5, we will build on a previous example of a simple CUDA kernel. For example, the following RGB picture of flowers
will look like this after running the filter:
and to execute the application we will call it like this:
This code will work with RGBA images where each channel (Red, Green, Blue, and Alpha) is represented by one byte (8-bits) and a range of values between 0 and 255 (2^8 – 1) for a total of 4-bytes per pixel.
Gray scale images are represented by a single intensity value per pixel where each pixel is only 1 byte, so after conversion we will have an image with only one channel and a pixel size of 1 byte.
Human eyes are more sensitive to green and least to blue. For that reason we will use weighted formula:
I = 0.2126 * R + 0.7152 * G + 0.0722 * B
Please read more here.