Page 1 of 1

Real Time Image Processing using CImg

Posted: Wed Apr 20, 2016 5:45 pm
by blvlohith
Problem : What is the C++ code to obtain gray scale image pixel intensity values using CImg library ?

Hi, everyone I’m a beginner to C++ and raspberrypi, Here I’m working on a project to capture the real time images using Raspberrypi CSI camera and to perform simple image processing operation in C++ using CImg library.

That is, to detect the bright spot in an image (such as LED light glow) and if detects the bright spot, output should be given as ‘1’ and if not (when the LED is off ) output should be given as ‘0’.

Note: The image processing has to be done only in the specific portion of an image (i.e focus only on the led section of an image and neglecting remaining portion of an image which is out of interest, such that it saves processing time and improves performance)

But firstly I don’t know how to get pixel intensity values of a gray scale image using CImg library such that we can compare the values obtained in the pixel to the threshold value and problem could be solved ( this is my algorithm for the above operation but any other simpler methods for the above processing ,your suggestions are always welcome )
Could you help me in a C++ code or algorithm to perform the above task.
Thanks in advance.

Re: Real Time Image Processing using CImg

Posted: Wed Apr 20, 2016 11:00 pm
by Goraxium
This sounds an awful lot like homework...

To get you started, check out the example on the bottom of this page:
http://cimg.eu/reference/group__cimg__loops.html
That code is used to blur an image, but the upside to it, is that it shows you how to define a subregion of an image, how to scan the entire image, and process the data in that region.

Given that the images in the examples just seem to be an array of floats, it should be a piece of cake to extract the intensity of the light in those regions. All you need to do is specify a baseline, and compare it from there. Having a minimum number of pixels to check will be a good idea as well, otherwise you can get false positives in low light due to noise.