# Reducing the number of GRAYSCALE levels (8 bits to 3 bits)

**URL:** <https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184>\
**Category:** OpenMV Boards\
**Created:** [March 29, 2019, 1:19am UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184 "2019-03-29T01:19:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jivrik](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@Jivrik](https://forums.openmv.io/u/Jivrik)\
**Post date:** [March 29, 2019, 1:19am UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184/1 "2019-03-29T01:19:49Z")

</div>

Hi,  
  
  
I am trying to reduce the grayscale level on the openMV frame. Instead of having a range of grayscale going from 0 to 255, I want a level of grayscale going from 0 to 7.

Is it possible?  
If yes, How can i do it ?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [March 29, 2019, 3:24am UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184/2 "2019-03-29T03:24:16Z")

</div>

Hi, download the latest firmware and use the gamma\_corr() method and set the contrast adjustment to be 0.03125.

[https://github.com/openmv/openmv/blob/master/scripts/examples/04-Image-Filters/gamma\_correction.py](https://github.com/openmv/openmv/blob/master/scripts/examples/04-Image-Filters/gamma_correction.py)

---

<div class="post-metadata">

**Author:** ![Jivrik](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@Jivrik](https://forums.openmv.io/u/Jivrik)\
**Post date:** [April 13, 2019, 12:15am UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184/3 "2019-04-13T00:15:05Z")

</div>

Hi,

Thank you.  
  
  
I got confused when trying to update the firmware.

Do I have to load a .dfu file from Tools \> run bootloader?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [April 13, 2019, 12:17am UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184/4 "2019-04-13T00:17:41Z")

</div>

Hi just use the firmware.bin file in the OPENMV3 folder for the M7. The H7 is the OPENMV 4 folder.

---

<div class="post-metadata">

**Author:** ![Jivrik](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@Jivrik](https://forums.openmv.io/u/Jivrik)\
**Post date:** [April 13, 2019, 12:48am UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184/5 "2019-04-13T00:48:49Z")

</div>

Please ,  
  
  
How do you get the numbers for the gamma correction?

What is the maximum value of the contrast and the brightness?  
  
  
Also I tried to print the pixels values collected using the operation below:

img = sensor.snapshot().gamma\_corr(gamma = 0.03125, contrast = 1.0, brightness = 0.0)

I keep having values between 0 and 255 ; and not 0 and 8 since I should have a 3 bits grayscale.

---

<div class="post-metadata">

**Author:** ![Jivrik](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@Jivrik](https://forums.openmv.io/u/Jivrik)\
**Post date:** [April 17, 2019, 11:12pm UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184/6 "2019-04-17T23:12:14Z")

</div>

Just in case you missed this question… Could you please help me out with this as well?

Thanks.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [April 18, 2019, 5:46am UTC](https://forums.openmv.io/t/reducing-the-number-of-grayscale-levels-8-bits-to-3-bits/1184/7 "2019-04-18T05:46:10Z")

</div>

Yeah… so, you want to pass the 0.03125 value to contrast, not gamma. The values are passed to every pixel channel normalized to 1. E.g. a brightness of 1 makes the whole image white and maxes everything out. Contrast of 2 multiplies all pixels by 2. Gamma is different and does the standard image gamma operation.
