# Normlizing an Image - image division and datatype conversion

**URL:** <https://forum.commonvisionblox.com/t/normlizing-an-image-image-division-and-datatype-conversion/553>\
**Category:** C-style API\
**Tags:** foundation, datatype\
**Created:** [September 14, 2018, 11:40am UTC](https://forum.commonvisionblox.com/t/normlizing-an-image-image-division-and-datatype-conversion/553 "2018-09-14T11:40:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard\_loewenherz](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/richard_loewenherz/32/176_2.png) [@richard\_loewenherz](https://forum.commonvisionblox.com/u/richard_loewenherz)\
**Post date:** [September 14, 2018, 11:40am UTC](https://forum.commonvisionblox.com/t/normlizing-an-image-image-division-and-datatype-conversion/553/1 "2018-09-14T11:40:55Z")

</div>

Hi,  
I’m trying to normalize an Image (_sample_) using a white reference (_wRef_) and a black reference (_bRef_):

```auto
sample_normalized = (sample - bRef) / (wRef - bRef)

```

The resulting image should have a value range of [0,1].  
For that I was thinking of using the Artihmetic functions in the CVFoundation.dll (`SubtractImages()` and `DivideImages()`). It seems that these function would always return an image of the same data type as the input.  
My problem here is that the input images are of data type `uint16` while my output image needs to be of type `float`…

So it it possible (and feasable) to convert my images from uint16 to float and then do the whole math.  
Are there any CVB functions to change the data type of an image?

---

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [September 14, 2018, 2:15pm UTC](https://forum.commonvisionblox.com/t/normlizing-an-image-image-division-and-datatype-conversion/553/2 "2018-09-14T14:15:36Z")

</div>

Hi @richard_loewenherz!

`ConvertTo32BPPFloat` or `ScaleTo32BPPFloat` should do the job.

---

<div class="post-metadata">

**Author:** ![richard\_loewenherz](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/richard_loewenherz/32/176_2.png) [@richard\_loewenherz](https://forum.commonvisionblox.com/u/richard_loewenherz)\
**Post date:** [September 17, 2018, 6:56am UTC](https://forum.commonvisionblox.com/t/normlizing-an-image-image-division-and-datatype-conversion/553/3 "2018-09-17T06:56:35Z")

</div>

Thanks a lot. I didn’t check the Foundation library for such functions.  
But this should do the trick!
