Hi, I'm searching for a fast way to substract a dark image from another image. If the dark image pixel value is greater than the corresponding image pixel, the resulting image pixel should be zero. Otherwise, it should be simply substracted.
Are there special functions for doing this job?
I got an AT91SAM9260 processor and the image data is 10bit depth, laying in a 16-bit array.
Many thank, Stefan
Stefan; I don't know your image size or your dynamic range but for limited range a Look Up Table (LUT) would be a very fast routine. The table would be filled with your dark image values and the real image value would index into the dark image array for the new value. This is a common hardware approach to pre-processing of images for machine control. Of course if your dark image values are dynamic as well as the real image this would not work. For a number of algorithms, look at "The Handbook of Astronomical Image Processing" by Richard Berry. ISBN 0-943396-67-0. I'm sure there is a much later edition. While it leans to Astrometry, images are images.
Hi, thanks for the current answers.
Al: Can you post a short example of the idea you mean? I don't got it... The pictures are 752*480 pixel with 10bit color depth (grayscale).
Stephan; I must leave the office quickly. Just go to Wikipedia and look up LUTs.
Al: Can you post a short example of the idea you mean? I don't got it...
I'll give it a try. I think the approach assumes that each pixel of the dark image has the same value, else you'd be looking at a two-dimensional lookup table that's [maximum image value] long in the first and [maximum dark image value] long in the second dimension. (This _might_ be feasible if the maximum dark image value is very small).
For simplicity, let's assume that the image is only 4 bits deep. The dark image value is set to be 5. Then you would build the following lookup table:
int image_lut[16] = {0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
and perform the following operation for each pixel of the image:
new_pixel[x][y] = image_lut[old_pixel[x][y]];
Note that, it can mean a lot if you can do the operation in-place, with only one to walk over the image data, instead of having a source and a destination pointer.
Note that, it can mean a lot if you can do the operation in-place, with only one to walk over the image data, instead of having a source and a destination pointer.<p>
Possibly, but I'd guess it's irrelevant on the ARM architecture, which has plenty of registers to keep the pointers in.
I would think that if the dark image really has a constant value, doing the actual subtraction + max operation instead of using a lookup table might be faster on an ARM. Memory accesses eat up cycles like crazy, compared to doing operations on registers.
If the OP is using assembly, he might also be able to use some clever tricks like loading two 16-bit pixels with one 32-bit read operation.
I think the approach with the LUT is only working for a constant dark image pixel value. But what I want to do, is to substract the fixed pattern noise (which is part of the dark image) and extraneous light.
So, what I have is: dark image [752][480] and another image [752][480]
E.g:
{{4,5,4,4}{7,4,4,3}{1,4,4,6}{1,4,5,5}} == image - {{1,3,2,0}{7,2,1,2}{0,1,1,4}{3,0,0,1}} == dark image ________________________________________ {{3,2,2,4}{0,2,3,1}{1,3,3,2}{0,4,5,4}}
You also mentioned saturation. Is it sorrect to assume that what you want is this:
for (x = 0; x < 752; x++) for (y = 0; y < 480; y++) if (dark[x][y] < image[x][y]) image[x][y] -= dark[x][y]; else image[x][y] = 0;
What's wrong with implementation in C? Did you try it? Is it too slow?
Currently I just use a similary implementation in C.
Since I have strange performance constraints, I want it to run as fast as possible. Maybe there is a way to get it faster using "special" commands or inline assembler (e.g. command QSUB - if I'm rigth).
View all questions in Keil forum