Display images with > 8 Bits

Next problem… When I assign an image to the display that has more than 8 bits per pixel I get a fairly weird display:

Is Common Vision Blox unable to display Images with more than 8 bits per pixel properly??

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! :wink:

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):

    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.
  • 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.
  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) - 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.

:exclamation: 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).


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?

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.

Thank you for the answer!