wkjarosz / hdrview

A simple research-oriented image viewer with an emphasis on examining and comparing high-dynamic range (HDR) images, and including minimalistic editing and tonemapping capabilities.
Other
279 stars 11 forks source link

.pfm image display is flipped vertically #118

Closed TzuChieh closed 6 months ago

TzuChieh commented 6 months ago

According to some sources[1][2], the .pfm format contains raster data ordered from left to right, bottom to top. However, I do find a disagreement[3]. I have attached an example .pfm file example.zip showing an area light shining the ground below it.

This is what GIMP 2.10.36 shows: image

And this is from HDRView v1.8.0 (64 bit Windows build): image

[1] https://www.pauldebevec.com/Research/HDR/PFM/ [2] The "PFM raster" section of https://netpbm.sourceforge.net/doc/pfm.html [3] The "PFM raster" section of https://linux.die.net/man/5/pfm

wkjarosz commented 6 months ago

Hi TzuChieh,

As you noted, there isn't universal agreement about the order pixels should be stored in a PFM, and (as far as I know), there is no way to determine this automatically from the header.

HDRView uses the same convention as Photoshop (as this is the tool I otherwise use most). Unfortunately, this is the opposite convention as macOS's Preview and Quicklook, and seemingly Gimp as well.

A work-around is to manually flip the pixels after you load them. Just open up the command palette and type "flip" and it should show up (or hit Opt+V"

wkjarosz commented 6 months ago

I'm going to mark this as closed for now. If you come up with a satisfying way to resolve this that doesn't simply shift the problem to files generated with software using the other convention, then please add a new comment or pull request and we can continue to discuss.

TzuChieh commented 6 months ago

Hi Wojciech,

Thank you for the tips! I am using Alt+V to flip PFM images for now and it works really well. Currently I cannot come up with a way to handle this without encoding new information into the file. Amazing software by the way 🙂!