【发布时间】:2011-06-11 04:07:44
【问题描述】:
我想弄清楚如何将图像从 uint16 转换为 uint8。我基本上必须以浮点数读取图像,并且需要以无符号字符显示它。
我有以下几点:
float two_eight = pow(2.0,8);
float two_sixteen = pow(2.0,16);
QImage *qi = new QImage(imwidth, imheight, QImage::Format_RGB32);
for (int i = 0 ; i < imheight ; i++)
{
for (int j = 0 ; j < imwidth ; j++)
{
floatData[i*imwidth+j] = (two_eight* floatData[i*imwidth+j])/two_sixteen;
qi->setPixel(j,i,qRgb((unsigned char)floatData[i*imwidth+j],(unsigned char)floatData[i*imwidth+j],(unsigned char)floatData[i*imwidth+j]));
}
}
在 Qt 中是否有更好的方法来执行此操作?
【问题讨论】:
标签: c++ image qt image-processing