# Display images with \> 8 Bits

**URL:** <https://forum.commonvisionblox.com/t/display-images-with-8-bits/29>\
**Category:** C-style API\
**Tags:** display, high-bit\
**Created:** [May 8, 2017, 1:12pm UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29 "2017-05-08T13:12:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![taserface](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@taserface](https://forum.commonvisionblox.com/u/taserface)\
**Post date:** [May 8, 2017, 1:12pm UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29/1 "2017-05-08T13:12:43Z")

</div>

Next problem… When I assign an image to the display that has more than 8 bits per pixel I get a fairly weird display:  
 ![](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/bb2e12a12f9ca64a4d5a60962dc8f8c3799b39d9.jpg)  
Is Common Vision Blox unable to display Images with more than 8 bits per pixel properly??

---

<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:** [May 8, 2017, 2:25pm UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29/2 "2017-05-08T14:25:59Z")

</div>

Hi @taserface!

Depending on what you consider a proper display for image data with more than 8 bits per pixel the answer is definitely yes! 😉

First: The slightly garbled display that you are seeing is only the _default_ way of Common Vision Blox to display images with more than 8 bits per pixels. What happens is this: Usually a device context in Windows is not capable of displaying more than 8 bits per pixel. When confronted with image data with more than 8 bits per pixels, the Common Vision Blox display therefore simply copies the lowest 8 bits of the pixels to be displayed to the device context. If, for example, your data has 10 bits per pixel (pixel values: [0…1023]), you will have 3 pixel values at which a wraparound occurs when incrementing by one: 255, 511 and 767. These give rise to the striking white-to-black transitions in the display. You can easily verify that the actual pixel data has no discontinuity by moving the mouse pointer through one of these transitions and having a look at the display’s status line (if the display is configured to show the grey values).

However, this is just the default way of Common Vision Blox to display high-bit images - there are different options available (and the default approach is simply the one that happened to be there first). If you want a visually more attractive display of high-bit images you have two options:

1. **Change the high bit scale mode from its default (`HBSM_WrapAround`) to something else.**  
The high bit scale mode may be changed by setting the display control’s `HighBitScaleMode` property or by selecting a different mode on the control’s property page (on the tab _Status Line Styles_):  
 ![](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/e24acf84da6931dfc781156d253e01d6accaa0f7.png)  
In addition to the default of `HBSM_WrapAround` there are (currently) two other options:

- **`HBSM_Global`**  
In this mode, the entire image’s grey scale range will be mapped to the range [0…255] for display. This mode will probably yield what you’d expect, but it’ll not show you the finer details that might be present in a high-bit image.  
 ![](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/af0a107c3958d73f11465914ab58515b019d8f94.jpg)
- **`HBSM_ViewPort`**  
This mode maps only the currently visible pixels (the view port) to the range [0…255], making also the finer details in a high-bit image visible. This mode is nice for closely inspecting an image but it may also be confusing because the displayed brightness of a pixel (x, y) is likely to change depending on the zoom state.  
 ![](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/48b1159e24a39ae78bf694a56bd4a9f1be0fa145.png)

1. Alternatively you may use the function `MapTo8Bits` from the _CVCImg.dll_ to convert a high-bit image to an 8 bit image. This is not exactly the same as using `HBSM_Global` because `HBSM_Global` always maps the theoretical grey value range (as determined from the data type identifier) to [0…255], whereas `MapTo8Bits` converts the range of values encountered in the image to [0…255].  
The main difference between `MapTo8Bits` and changing the `HighBitScaleMode` is of course that the latter only acts on the display whereas the first will generate a new image with modified image data (which you can then subsequently assign to a Common Vision Blox display… this post might come in handy in that scenario: [Setting the image property on the display control resets the zoom state](http://forum.commonvisionblox.com/t/setting-the-image-property-on-the-display-control-resets-the-zoom-state/27/4?u=illusive)) - making this the approach of choice when the processed image should not only be used for display, but also for processing in a different tool.  
By the way: The _CVFoundation.dll_ has a function called `DownShift` that can be used to achieve the same results that `HBSM_Global` (simply shift down by enough bits to make sure that the value range does not exceep [0…255] any more) and is typically a lot faster than `MapTo8Bits`.

❗ Please keep in mind that the `HighBitScaleMode` value has no influence on the display’s appearance if the display is using DirectDraw or Direct3D (property `DirectDrawEnabled` set to `true`).

---

<div class="post-metadata">

**Author:** ![Jakob](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jakob](https://forum.commonvisionblox.com/u/Jakob)\
**Post date:** [August 2, 2018, 11:23am UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29/3 "2018-08-02T11:23:51Z")

</div>

Is there a way to change the high bit scale mode from software?  
In particular, can the scale mode be set for an ImageView (CVB++)?  
Or is my only option to convert the image to 8bit?

---

<div class="post-metadata">

**Author:** ![Andreas](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/andreas/32/75_2.png) [@Andreas](https://forum.commonvisionblox.com/u/Andreas)\
**Post date:** [August 2, 2018, 3:10pm UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29/4 "2018-08-02T15:10:13Z")

</div>

Hi @Jakob

currently the ImageView only supports Mono8 and RGB8 images.  
So yes, if you want to use the ImageView class e.g. `Cvb::MapTo8Bit` from algorithm.hpp is required to convert the high bit image.

---

<div class="post-metadata">

**Author:** ![Jakob](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jakob](https://forum.commonvisionblox.com/u/Jakob)\
**Post date:** [August 2, 2018, 3:24pm UTC](https://forum.commonvisionblox.com/t/display-images-with-8-bits/29/5 "2018-08-02T15:24:47Z")

</div>

Thank you for the answer!
