# Preferred numeric type for image processing algorithms

**URL:** <https://forum.opencv.org/t/preferred-numeric-type-for-image-processing-algorithms/313>\
**Category:** Uncategorized\
**Created:** [December 14, 2020, 4:32pm UTC](https://forum.opencv.org/t/preferred-numeric-type-for-image-processing-algorithms/313 "2020-12-14T16:32:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![exbigboss](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/exbigboss/32/196_2.png) [@exbigboss](https://forum.opencv.org/u/exbigboss)\
**Post date:** [December 14, 2020, 4:32pm UTC](https://forum.opencv.org/t/preferred-numeric-type-for-image-processing-algorithms/313/1 "2020-12-14T16:32:40Z")

</div>

Hey everyone,

I was just wondering, should one prefer something like `uchar` or `float` when doing a lot of heavy image processing?

I’ve been leaning towards using nothing but `CV_F32` but was just wondering if this is considered an anti-pattern.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [December 14, 2020, 6:42pm UTC](https://forum.opencv.org/t/preferred-numeric-type-for-image-processing-algorithms/313/2 "2020-12-14T18:42:40Z")

</div>

wouldn’t this be specific to your actual processing pipeline (which is ?) ?

i don’t think, that there’s a “general answer” to this

---

<div class="post-metadata">

**Author:** ![exbigboss](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/exbigboss/32/196_2.png) [@exbigboss](https://forum.opencv.org/u/exbigboss)\
**Post date:** [December 14, 2020, 7:06pm UTC](https://forum.opencv.org/t/preferred-numeric-type-for-image-processing-algorithms/313/3 "2020-12-14T19:06:59Z")

</div>

Ah, fair.

I’m working on some routine that lazily take 8-bit sRGB data and convert them to linear RGB data as `float`s.

To this end, it’s a lot easier to do things like white balance, convert to grayscale (I know OpenCV already has a function for this) and just other math in general.

Seems to weird people out to do this but maybe that’s because they’re used to libraries handling this for them.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [December 14, 2020, 9:26pm UTC](https://forum.opencv.org/t/preferred-numeric-type-for-image-processing-algorithms/313/4 "2020-12-14T21:26:36Z")

</div>

since you’re working with gamma curves, I would stick with floats as well.

the pushback against floats you might be getting tends to come from people who have no idea that gamma mapping even exists, or that it matters when calculating on pictures (resampling as a particularly obvious case).
