Converting gammaTRC values from 32 bits tiffs and logluv input images to linear

This commit is contained in:
natureh 510
2013-01-15 19:08:02 +01:00
parent 79a5c501ef
commit 1b41c6a4db
2 changed files with 27 additions and 12 deletions

View File

@@ -655,10 +655,31 @@ int ImageIO::loadTIFF (Glib::ustring fname) {
delete [] loadedProfileData;
loadedProfileData = NULL;
}
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &loadedProfileLength, &profdata)) {
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &loadedProfileLength, &profdata)) {
embProfile = cmsOpenProfileFromMem (profdata, loadedProfileLength);
loadedProfileData = new char [loadedProfileLength];
memcpy (loadedProfileData, profdata, loadedProfileLength);
// For 32 bits floating point images, gamma is forced to linear in embedded ICC profiles
if ( sampleFormat&(IIOSF_LOGLUV24|IIOSF_LOGLUV32|IIOSF_FLOAT) ) {
// Modifying the gammaTRG tags
cmsWriteTag(embProfile, cmsSigGreenTRCTag, (void*)Color::linearGammaTRC );
cmsWriteTag(embProfile, cmsSigRedTRCTag, (void*)Color::linearGammaTRC );
cmsWriteTag(embProfile, cmsSigBlueTRCTag, (void*)Color::linearGammaTRC );
// Saving the profile in the memory
cmsUInt32Number bytesNeeded = 0;
cmsSaveProfileToMem(embProfile, 0, &bytesNeeded);
if (bytesNeeded > 0) {
loadedProfileData = new char[bytesNeeded+1];
cmsSaveProfileToMem(embProfile, loadedProfileData, &bytesNeeded);
}
loadedProfileLength = (int)bytesNeeded;
}
else {
// Saving the profile in the memory as is
loadedProfileData = new char [loadedProfileLength];
memcpy (loadedProfileData, profdata, loadedProfileLength);
}
}
else
embProfile = NULL;
@@ -686,12 +707,14 @@ int ImageIO::loadTIFF (Glib::ustring fname) {
pl->setProgress ((double)(row+1)/height);
}
if (sampleFormat & (IIOSF_FLOAT|IIOSF_LOGLUV24|IIOSF_LOGLUV32)) {
//if (options.rtSettings.verbose)
#ifdef _DEBUG
if (options.rtSettings.verbose)
printf("Normalizing \"%s\" image \"%s\" whose mini/maxi values are:\n Red: minimum value=%0.5f / maximum value=%0.5f\n Green: minimum value=%0.5f / maximum value=%0.5f\n Blue: minimum value=%0.5f / maximum value=%0.5f\n",
getType(), fname.c_str(),
minValue[0], maxValue[0], minValue[1],
maxValue[1], minValue[2], maxValue[2]
);
#endif
float minVal = min( min( minValue[0],minValue[1] ),minValue[2] );
float maxVal = max( max( maxValue[0],maxValue[1] ),maxValue[2] );
normalizeFloat(minVal, maxVal);

View File

@@ -166,14 +166,6 @@ int StdImageSource::load (Glib::ustring fname, bool batch) {
embProfile = img->getEmbeddedProfile ();
// For 32 bits floating point images, gamma is forced to linear in embedded ICC profiles
// HOMBRE: Doesn't seem to have any effect
if ( (sFormat&(IIOSF_LOGLUV24|IIOSF_LOGLUV32|IIOSF_FLOAT) ) && embProfile) {
cmsWriteTag(embProfile, cmsSigGreenTRCTag, (void*)Color::linearGammaTRC );
cmsWriteTag(embProfile, cmsSigRedTRCTag, (void*)Color::linearGammaTRC );
cmsWriteTag(embProfile, cmsSigBlueTRCTag, (void*)Color::linearGammaTRC );
}
idata = new ImageData (fname);
if (idata->hasExif()) {
int deg = 0;