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. related to generate Heatmap

related to generate Heatmap

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 5 Posters 1.1k Views 3 Watching
  • 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.
  • X Offline
    X Offline
    xylo212
    wrote on last edited by
    #1

    I have dataset of Temperature in the form of string,
    around 5000 data length of that data and they are in degree celsius.
    Now, I want to generate heatmap from this data in qt cpp.

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      How nice.
      What is a heatmap? And what is your question?

      Software Engineer
      The Qt Company, Oslo

      Pl45m4P 1 Reply Last reply
      0
      • Axel SpoerlA Axel Spoerl

        How nice.
        What is a heatmap? And what is your question?

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by Pl45m4
        #3

        @Axel-Spoerl said in related to generate Heatmap:

        What is a heatmap?

        A graphical representation of data showing an image with colors from dark blue or even white ("cold" = min value) over yellow and orange shades to red ("hot" = max value) .

        @xylo212
        I don't think Qt supports this out-of-box. Either create one of your own using QImage pixel manipulation or look into some 3rd party library like OpenCV which is made for things like this and even has a function to generate heatmaps.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xylo212
          wrote on last edited by
          #4

          heat map (or heatmap) is a 2-dimensional data visualization technique that represents the magnitude of individual values within a dataset as a color. The variation in color may be by hue or intensity.

          We show it in rgb color only.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xylo212
            wrote on last edited by
            #5

            I don't have image for pixel manipulation, I just have a string of temperatures, What I thought earlier to convert each temperature points into rgb data points ,so can u tell me how can I convert each data points of temperature into rgb data point

            Pl45m4P 1 Reply Last reply
            0
            • Axel SpoerlA Offline
              Axel SpoerlA Offline
              Axel Spoerl
              Moderators
              wrote on last edited by
              #6

              You could look into the implementation of QColorDialog.

              Software Engineer
              The Qt Company, Oslo

              1 Reply Last reply
              0
              • X xylo212

                I don't have image for pixel manipulation, I just have a string of temperatures, What I thought earlier to convert each temperature points into rgb data points ,so can u tell me how can I convert each data points of temperature into rgb data point

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by Pl45m4
                #7

                @xylo212 said in related to generate Heatmap:

                how can I convert each data points of temperature into rgb data point

                Normalize your temperature data from min-max to 0 - 255.
                Then apply your mapping function to map the single channel (grayscale) values to heatmap colors.
                e.g. OpenCV uses different mappings like "JET", "VULCANO" (no shades of blue, just yellow orange and red) or what they are called. Each of them colorizes the heatmap differently.


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                1 Reply Last reply
                2
                • J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  I have this very old example where I implemented noise algorithms to create a random but coherent hight map using grey scale
                  https://github.com/DeiVadder/QNoise

                  Maybe it's of help to you


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  0
                  • X Offline
                    X Offline
                    xylo212
                    wrote on last edited by
                    #9

                    Thanks @J-Hilk I'm trying to use QPainter method to show heatmap right now,
                    1.I convert string data into 2d vector
                    2.convert each temperature into rgb using normalisation,normalizedTemp = (temperature - minTemp) / (maxTemp - minTemp);
                    3.store rgb value of each rgb temp into 2d array
                    4.Then I use QPainter ,,
                    QColor color = QColor::fromHsv((240 - grayscaleValue * 240 / 255), 255, 255);
                    //(240 - grayscaleValue * 240 / 255), 255, 255
                    // Fill rectangle with the mapped color
                    // QRect rect(400,400,500,500);
                    painter.fillRect(col * cellWidth, row * cellHeight, cellWidth, cellHeight, color)
                    I do this for Each data entery store in 2d array,,
                    for grayscsle,
                    int HeatMap::rgbToGrayscale(QRgb color) {
                    // Convert RGB to grayscale using luminosity method
                    int red = qRed(color);
                    int green = qGreen(color);
                    int blue = qBlue(color);
                    //qDebug()<<red<<" red "<<green<<" green "<<blue<<" blue ";
                    return static_cast<int>(0.2126 * red + 0.7152 * green + 0.0722 * blue);//this is correct
                    //return static_cast<int>(0.3126 * red + 0.3126 * green + 0.0016 * blue);
                    }

                    1 Reply Last reply
                    0
                    • X Offline
                      X Offline
                      xylo212
                      wrote on last edited by
                      #10

                      What should I need to correct on my approach?

                      D 1 Reply Last reply
                      0
                      • X xylo212

                        What should I need to correct on my approach?

                        D Offline
                        D Offline
                        DerReisende
                        wrote on last edited by
                        #11

                        @xylo212 why don‘t you google for it? you would have found this library.
                        it also has an example to generate a png from the data in the examples folder.

                        1 Reply Last reply
                        0

                        • Login

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