ich habe mit meinen RGB-Werten ein kleines Problem. Die Farben verlaufen so, dass weiss = 2 (Achsenkoordinate) und schwarz = 0 entpsricht. Jetzt möchte ich aber, dass Grau = 0 ist, so dass weiss= 1 und schwarz=-1 ist, aber ich weiss nicht ganz genau wo ich das ändern muss. Kann mir bitte jmd helfen,danke.
Code: Alles auswählen
QVector<QRgb>
TabEins::i16ImageToRGB(const I16Image &img) const {
QVector<QRgb> rgbData;
rgbData.reserve(img.width()*img.height());
I16Image::Pixel maxPixVal = std::numeric_limits<I16Image::Pixel>::max();
uint8 maxByteVal = std::numeric_limits<uint8>::max() ;
double scale = static_cast<double>(maxByteVal)/static_cast<double>(maxPixVal);
//double scale static_cast<double>()/static_cast<double>()
for(int iy = 0 ; iy < img.height() ; iy++) {
for(int ix = 0 ; ix < img.width() ; ix++) {
double imgValue = img.value(ix, iy) ;
uint8 greyValue = static_cast<uint8>(scale * imgValue + 0.5); // 0,5 in 1 umgewandelt
QRgb rgb = qRgb(greyValue, greyValue, greyValue);
rgbData.append(rgb);
}
}
return rgbData;
}
nici