// Load the cube faces void LoadCubeFace(GLenum target, char *filename) { FILE *file; // load image and get pixels STImage *image = new STImage(filename); const STColor4ub* pixels = image->GetPixels(); // build mipmaps gluBuild2DMipmaps(target, GL_RGBA, image->GetWidth(), image->GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, pixels); }
STHDRImage* recover_hdr(vector<Photo>& photos, CameraResponse& response) { int width,height; STImage *tmpImage = new STImage(photos[0].filename); width = tmpImage->GetWidth(); height = tmpImage->GetHeight(); delete tmpImage; STHDRImage *newImage = new STHDRImage(width,height); vector< vector<STColor3f> > Ls; vector< vector<STColor3f> > ws; vector< vector<STColor3f> > Lw; for (int i=0;i<width;i++) { vector<STColor3f> row; for (int j=0;j<height;j++) { STColor3f zero(0); row.push_back(zero); } Ls.push_back(row); ws.push_back(row); Lw.push_back(row); } for (int k=0;k<photos.size();k++) { //open photo STImage currentImage(photos[k].filename); //perform calculations for (int i=0;i<width;i++) { for (int j=0;j<height;j++) { STColor4ub currentPixel = currentImage.GetPixel(i, j); Ls[i][j].r += (response.Weight(currentPixel).r * (response.GetExposure(currentPixel).r - logf(photos[k].shutter) ) ); Ls[i][j].g += (response.Weight(currentPixel).g * (response.GetExposure(currentPixel).g - logf(photos[k].shutter) ) ); Ls[i][j].b += (response.Weight(currentPixel).b * (response.GetExposure(currentPixel).b - logf(photos[k].shutter) ) ); ws[i][j] += response.Weight(currentPixel); } } for (int i=0;i<width;i++) { for (int j=0;j<height;j++) { Lw[i][j].r = expf(Ls[i][j].r / ws[i][j].r); Lw[i][j].g = expf(Ls[i][j].g / ws[i][j].g); Lw[i][j].b = expf(Ls[i][j].b / ws[i][j].b); newImage->SetPixel(i, j, Lw[i][j]); } } } return newImage; }