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. Right format to use to display an image cv::Mat CV_32F normalized

Right format to use to display an image cv::Mat CV_32F normalized

Scheduled Pinned Locked Moved Unsolved General and Desktop
opencvqt imageimage
2 Posts 2 Posters 936 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.
  • R Offline
    R Offline
    Rui f
    wrote on 25 Aug 2021, 12:49 last edited by
    #1

    I have an image cv::Mat CV_32F normalized like this:

    depthImage.convertTo(depthImageNormalized, CV_32F, 1.0 / 65535, 0);
    normalize(depthImageNormalized, depthImageNormalized, 0, 1, cv::NORM_MINMAX);

    And I want to display it on a label

    ui->label_phone_depth->setPixmap(QPixmap::fromImage(QImage(depth.data, depth.cols, depth.rows, depth.step, QImage::Format_Grayscale16)));

    On the left image you can see the original image, and on the left what is outputted

    98f4ccfc-792d-4cff-87c4-3d5fcbddfdc0-image.png

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Aug 2021, 18:04 last edited by
      #2

      Hi and welcome to devnet,

      You can't jump from a 32bit float image to 16bit integer one like that.

      Convert your OpenCV image to 16 bit before making a QImage out of it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      1/2

      25 Aug 2021, 12:49

      • Login

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