Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Display 2D array of type Uint16 * as grayscale image
QtWS25 Last Chance

Display 2D array of type Uint16 * as grayscale image

Scheduled Pinned Locked Moved Unsolved General and Desktop
image displayqimagedata conversion
2 Posts 2 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Donn
    wrote on 28 Feb 2016, 16:59 last edited by Donn
    #1

    I have a pointer to my image pixel values represented as Uint16 data type. I want to display it as a grayscale image in Qt. Is the QImage::QImage suitable for this task? If yes, how can I convert Uint16 * to uchar * ? Moreover, how to make grayscale image? I tried all the provided maps but no one displays it well.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      michelson
      wrote on 28 Feb 2016, 22:30 last edited by
      #2

      <0, 65535> ---> <0,255> pixel by pixel so probably not the fastest

      for(int r = 0; r < rows; r++)
      {
          for(int c = 0; c < rows; r++)
          {
              uchar_data[r][c] = (uchar)( (uint16_data[r][c] - (uint16_data[r][c]%256) )/256 );
          }
      }
      
      1 Reply Last reply
      0

      2/2

      28 Feb 2016, 22:30

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved