History of binning a picture

Dear followers,

After a very long time, we finally managed to solve a simple problem, perform an on-live 4×4 binning to the pictures taken from the camera. This process is quite simple, we just need to take the pixels, make the columns binning by summing up each 4 of them and storing them into a FIFO queue (First Input First Output). Then, when the next line of pixels arrives, it is just to add them as before and add to them the previous 4 and store them again. After 4 times we have a full line make of 4×4 binned pixels. Then, it is just to save into our memory and later one retrieve the picture for plotting on Matlab.

Okay, once you get the concept, it is easy, isn’t it? However I was fighting a problem, the pictures were always wrong, the pixels shifted and strange values where in all of them. I checked the algorithm hundred of times, I discussed with other people about it in order to find the error, I tested it in different ways, and it was okay but some small issues. However it didn’t work, it was frustrating! Indeed, time was running and it wasn’t working yet.

Fortunately, few days ago, during a long simulation on ModelSim (a special software for checking the VHDL firmware without loading it into a device) shows something unusual. At one point, a COST component, generated by the tool that I was using for designing the firmware got an unexpected value. That gave me the key! This COST component was the FIFO, the same in which I was saving the values before sending into the memory. It wasn’t behaving in a normal mode. After that, I decided to make some modifications on that component, which shall be said, has been used successfully in different projects. The point is that we have a lot of free space in our FPGA but a small amount of RAM memory, which is used to build up the FIFO. For this reason I decided to use FIFO sizes different from a power of 2 (in digital electronics, that is magic). That strange manipulation is possible and the tool says that it is supported, however, after changing the size values to a power of 2, by wasting some RAM on it, the binning got life! The problem was solved!

Now, we have to keep working and take the next steps, we already have lost a lot of time with this bug, but now we know that this bug exists, and we can take care about it. However, and even after the fact that now the binning it’s working just by changing in there, I would like to double-check that the error is in there and if after that we think so, report it for the sake of all possible engineers which are dealing or will deal with the same problem.

And as a prof of that it works, here is the first picture taken with the binning fully operative!


Okay, it’s not the best picture ever, National Geographic won’t use it but remember, we will use this camera for tracking a powerful light, not for taking team pictures! or maybe…..


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s