Refactor and clarify the specification of Image containers
What are the problems?
Colour image
There is currently no clear specification about what shall contain a ColorImage
. Is it sRGB, is it RGB?
Why is this an issue?
The colour image have several save function which more or less write the raw colour value to the file regardless of the format. But, a EXR is generally a linear RGB while a PNG is sRGB if no ICC profile is provided.
Hence, doing
colorImage.save("img.exr");
colorImage.save("img.png");
does not have a very clear behaviour.
Furthermore, savePNG
multiply the values by 255... So, it is already applying a conversion.
What do I suggest?
A - ColorImage
shall be an abstract class (will develop on that later)
B - ColorImage
shall assume the pixels are linear values (XYZ, RGB ? I would be for XYZ)
C - ColorImage
shall be renamed accordingly (XYZImage
or RGBImage
)
Refactoring
I suggest a refactoring of the hierarchy of the Image classes. I am not an UML expert so excuse the approximations but here it is.
Each of the Image shall implement the copy operator. This will ease image conversion.
Also, I would avoid public load instance functions. I would prefer constructor in the corresponding class (for instance SpectralImage *img = new EnviSpectralImage("foo.hdr");
). That does not mean we cannot have static load factories in each class.
Since this architecture is highly a personal taste and not the only way to implement it, I am opening discussion (and probably trolls ;) ) threw this issue.
Questions about colour conversion / tonemapping
I have the feeling that we do it wrong for Reinhard tonemapping.
I think we shall consider this tonemapping function (and any tomemapping function) transforming a linear RGB space into another RGB space represented as linear value. What do I mean? I think we shall apply anyway a sRGB gamma correction whatever the tonemapping function we are using in case we intend to display the result on a 8bit / channel monitor or on a image without an ICC profile. If there is an ICC profile, the colours shall be consider as linear RGB and then converted in the specified ICC colourspace.
Why? A tonemapping function is "just" a luminance / colour adaptation. sRGB is an old standard still in used to colour correct an RGB colour on a non linear monitor (cathodic monitor). This have nothing to do with the perceptive tonemapping function.
Am I correct there or do I miss something?