related to generate Heatmap
-
How nice.
What is a heatmap? And what is your question? -
@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 usingQImage
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. -
-
You could look into the implementation of
QColorDialog
. -
@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. -
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/QNoiseMaybe it's of help to you
-
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);
} -
@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.