Embedded Eye

Give your gizmo the gift of sight

Hi,

I have a question regarding the calculation of the mask (I refer to the Stonyman/Hawksbill vision chip library “ArduEye_SMH.h”).

The function calcMask finds the minimum (pixel) value of an image and subtract it from each pixel of the image. The result is the mask.

Code: mask[i] = img[i] - *mask_base; => ("mask_base" is the minimum)

The function applyMask applies the mask to an image.

Code: img[i] -= mask_base+mask[i];

If I rewrite the code (without the short form) I will get: img[i] = img[i] – (mask_base+mask[i]);

But the calculation of the mask is “mask[i] = img[i] - *mask_base;” of course with a different image.

So if we put everything together:

(1): mask[i] = img_a[i] - *mask_base; => calcMask

(2): img_b[i] = img_b[i] – (mask_base+mask[i]); => applyMask

(3): img_b[i] = img_b[i] – (mask_base+ img_a[i] - *mask_base); => (1) and (2) combined

(4): img_b[i] = img_b[i] – img_a[i]; => (1) and (2) further combined

Is this calculation correct? I hope you understand what I mean?

If I use the code above the results are not ok.

So I use simply “img[i] = img[i] - mask[i];” .

What is your opinion?

Thank you.

Michael

 

Views: 162

Reply to This

Replies to This Discussion

Yes this calculation is correct. img_a is the image grabbed when the texture is blank.

The reason we use mask_base and mask[i] rather than putting everything in mask[i] is that if we first subtract out the base, then we can use just 8-bit values for mask[], otherwise we'd have to use an array of 16-bit values for mask[] which would require more memory. But if you are not memory limited e.g. can use a smaller image array, or are using a processor with more memory, you can use just img[i] -= mask[i] as you suggest.

RSS

© 2022   Created by Geoffrey L. Barrows.   Powered by

Badges  |  Report an Issue  |  Terms of Service