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. Select pixel values from a displayed image
QtWS25 Last Chance

Select pixel values from a displayed image

Scheduled Pinned Locked Moved Solved General and Desktop
imagedisplaypoint selection
4 Posts 2 Posters 2.8k 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 8 Mar 2016, 07:55 last edited by
    #1

    Is there a way after displaying an image to select the wanted pixel values from the image? For example, I display a grayscale image and want to select some pixel values - location of it and the value and save it in some data structure in my app to further do some stuff with it.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 8 Mar 2016, 08:58 last edited by mrjj 3 Aug 2016, 09:00
      #2

      hi
      you can access pixels using QImage

      
      QRect area(0, 0, 100, 100); // set to some area
      //grab area from pixmap
      QImage image = pixmap()->toImage().convertToFormat(QImage::Format_RGB888).copy(area);
      double row = image.width();
      double col = image.height();
      for(int i = 0; i < row; i++) {
        for(int j = 0; j < col; j++) {
          double intensity = image.pixel(i, j);
        }
      }
      
      1 Reply Last reply
      1
      • D Offline
        D Offline
        Donn
        wrote on 8 Mar 2016, 10:30 last edited by
        #3

        Thank you for your reply. Maybe I formulated my question not very precisely but after displaying an image I want to select the particular pixels with my mouse, say 10 pixels, which are located at different positions and save those locations (maybe including values) to some data structure in my app.

        Even better, it would be perfect to be able to draw an arbitrary shape of the contour in the image with the mouse and extract those pixels which lie on this contour. Is it possible to do with Qt or do I need additional libraries?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 8 Mar 2016, 10:36 last edited by
          #4

          well using
          MouseMoveEvent you can see
          where mouse is all the time and you can then use
          Image.pixel(x,y) to read pixel values.

          So yes its possible.

          1 Reply Last reply
          0

          3/4

          8 Mar 2016, 10:30

          • Login

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