Qt : imagesc simple code
I am very interested with imagesc function in matlab. We can plot our data and plot image with user defined colormap. I have try to create a Qt: imagesc simple code using QPainter. This is a simple idea how to create Qt imagesc simple code. You can modified this code like your problem.
This code create a random data with size wdata(width) and hdata(height). I am create a winter colormap using colormap matlab function. You can get other colormap with looking at colormap matlab function. This is a code how to create winter colormap :
//create winter colormap
int **drawingWidget::Winter()
{
int **cmap = array2int(m_colorMapLength, 4);
float *winter = new float[m_colorMapLength];
for (int i = 0; i < m_colorMapLength; i++)
{
winter[i] = 1.0f * i / (m_colorMapLength - 1);
cmap[i][0] = 255;
cmap[i][1] = 0;
cmap[i][2] = (int)(255 * winter[i]);
cmap[i][3] = (int)(255 * (1.0f - 0.5f * winter[i]));
}
delete [] winter;
return cmap;
}
We can convert our data to colormap using this function :
//convert our data to colormap color
QRgb drawingWidget::GetColor(float f)
{
int r, g, b, a;
float tmp1 = (m_colorMapLength * (f - minData) + (maxData - f));
float tmp2 = (maxData - minData);
int cindex = (int) round( tmp1/tmp2 );
if (cindex < 1)
cindex = 1;
if (cindex > m_colorMapLength)
cindex = m_colorMapLength;
//int alpha = cmap[cindex - 1, 0];
r = cmap[cindex - 1][1];
g = cmap[cindex - 1][2];
b = cmap[cindex - 1][3];
a = 255;
QRgb value = qRgba(r, g, b, a);
return value;
}
You will get more information after reading my code. This is an output when running this Qt imagesc simple code :

You can download the full Qt imagesc simple code at here
Konular mükemmel olduğu gibi site teması da içeriğe müthiş uyum sağlamış. Tebrikler
Kayseri seyahatlerinizde ulaşım konforunu artırmak için Kayseri araç kiralama seçeneklerini değerlendirebilirsiniz.
Thanks for publishing this. The information is easy to understand and useful. For Mercedes-Benz parts and tuning, AutopartsMarketplace.lt is worth a mention.
hatay antakya çiçekçi, antakya çiçekçi
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Very helpful article. Thank you for sharing this information. For new and used automotive parts, readers can also check AutoScandi.com.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://www.binance.com/register?ref=GGYHGRE
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I like the efforts you have put in this, regards for all the great content.
Your article helped me a lot, is there any more related content? Thanks! https://accounts.binance.com/register/person?ref=JW3W4Y3A
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me? https://www.binance.bh/register?ref=L4EUT9FG
This is my first time pay a quick visit at here and i am really happy to read everthing at one place