fredmiranda.com
Login

Moderated by: Fred Miranda
  New fredmiranda.com Mobile Site
  New Feature: SMS Notification alert
  New Feature: Buy & Sell Watchlist
  

FM Forums | Sony Forum | Join Upload & Sell

  

Archive 2021 · HEIF vs JPG Image Quality Comparison

  
 
snapsy
Offline
• • • • • •
Upload & Sell: On
p.1 #1 · HEIF vs JPG Image Quality Comparison


Newer cameras such as the A7s III, A1, and 1DX III support the HEIF format as a newer option vs JPG. HEIF offers support for up to 16-bits per color vs JPG's 8-bits, which means more tonal range. HEIF also uses a more advanced compression algorithm, borrowed from H.265 (HEVC). Lastly, HEIF's container has more flexibility, including support for multiple images and mix of images/video in a single file, metadata transform support so that images can be instructed to crop, rotated, zoom, etc.. non-destructively, and transparency/alpha channel.

I was interested in how the image quality compares to JPG vs the space savings from the compression, so I created a 512x512 lossless test image composed of various images/patterns I found online and ran that image through Photoshop's JPG conversion at each quality level from 100 to 0.

For HEIF I converted the same lossless PNG to HEIF using heif_enc.exe (libheif), which can be found here. Photoshop is able to read HEIF images (but not write) on Windows when using Microsoft's HEIF Image Extensions (free), which requires Microsoft's HEVC Video Extensions ($0.99). Unfortunately those extensions don't seem to support 10-bit HEIFs or HEIFs encoded using 4:4:4 or 4:2:2 chroma sampling - it only seems to support 4:2:0. To work around this I converted the HEIF's back to lossless PNG using heif_convert.exe, which is included in the same libheif binary build.

There are a lot of provisos for this comparison. First, due to the dearth of HEIF support in image apps right now I had to rely on a single tool (libheif) for the HEIF conversions (although it relies on a mature x265 library), so the quality of the conversions from that tool plays an unknown factor in the HEIF files I produced. Second, the test image I created may not be fully representative of real-world images/performance since it includes some non-photographic elements designed to stress the chroma sampling of the compression algorithms.

Here is a composite image comparing JPG vs HEIF at various quality/compression levels. Note that the specific quality level settings between PS and libheif are not directly comparable so you may want to instead use the file sizes in the captions to decide which images to compare. For HEIF I used all three chroma sampling settings supported at each quality level - 4:4:4, 4:4:2, and 4:4:0. For JPG, Photoshop uses 4:4:4 for quality levels 60 to 100 and 4:2:0 for levels 50 and below.

Sony supports 4:2:0 and 4:2:2 in their cameras' HEIF support (link). It's not clear what chroma encoding Canon supports on the 1DX III but I did find a 1DX III HEIF online and it was 4:2:2.

HEIF vs JPG Comparison Composite Image (2469x6540, 13.7MB)

Observations:

  1. The 4:2:2 chroma sampling has a significant impact on IQ for the artifical test pattern (colored concentric circles) on HEIFs, even at maximum quality level. Since the maximum chroma sampling that Sony supports for HEIFs is 4:2:2 this may have an impact on specific real-world shooting scenarios, for example multi-colored patterns on fabrics.
  2. Oddly, the 4:2:2 HEIF conversion file sizes from heif_enc.exe are larger than the 4:4:4 conversions.




Mar 05, 2021 at 02:34 PM
mcbroomf
Offline
• • • • •
Upload & Sell: Off
p.1 #2 · HEIF vs JPG Image Quality Comparison


Nice job ... looks like size matters


Mar 05, 2021 at 03:30 PM
Hillrg`
Offline
• •
Upload & Sell: Off
p.1 #3 · HEIF vs JPG Image Quality Comparison


As you say HEIF looks promising. I understand why few applications fully support it yet - it is difficult to find full documentation required to write the code, each manufacturer can create their own boxes without documentation, and the libraries are out of date. The format is all about compression efficiency and flexibility such that the decoding efficiency takes a hit. I'm finding it takes ~3-4x longer to decode vs JPG. As processors improve and perhaps the decoding is moved to hardware this will improve. My experiments showed that image backgrounds with subtle hue shifts that pixelate in JPG hold together much better in 10 bit HEIF.


Mar 05, 2021 at 03:31 PM
johnctharp
Offline
• • • • •
Upload & Sell: Off
p.1 #4 · HEIF vs JPG Image Quality Comparison


Hillrg` wrote:
As you say HEIF looks promising. I understand why few applications fully support it yet - it is difficult to find full documentation required to write the code, each manufacturer can create their own boxes without documentation, and the libraries are out of date. The format is all about compression efficiency and flexibility such that the decoding efficiency takes a hit. I'm finding it takes ~3-4x longer to decode vs JPG. As processors improve and perhaps the decoding is moved to hardware this will improve. My experiments showed that image backgrounds with subtle hue shifts that pixelate in JPG hold
...Show more

H265 hardware, at least, is pretty prolific, but I'm betting that software hasn't even come close to leveraging for HEIF transcoding.

It's hard enough to get software to use that hardware for video transcoding as it is, and we're really SOL if we have to rely on Adobe for it.



Mar 05, 2021 at 06:33 PM
EB-1
Offline
• • • • • • •
Upload & Sell: Off
p.1 #5 · HEIF vs JPG Image Quality Comparison


What is the use case - PJ and commercial works?

EBH



Mar 05, 2021 at 07:21 PM
Eruditass
Offline
• • •
Upload & Sell: Off
p.1 #6 · HEIF vs JPG Image Quality Comparison


mcbroomf wrote:
Nice job ... looks like size matters


What do you mean exactly? Of course size matters, but algorithm matters more than size here, at least at lower file sizes.



Mar 05, 2021 at 07:55 PM
Eruditass
Offline
• • •
Upload & Sell: Off
p.1 #7 · HEIF vs JPG Image Quality Comparison



EB-1 wrote:
What is the use case - PJ and commercial works?

EBH


Perhaps high dynamic range and high color bit depth images. Finally a reasonable lossy format that can support those.

We don't have the issue of people sharing horrible lossy small JPG files as much these days, but HEIF certainly handles those much better.

I won't be shooting HEIF, but maybe eventually I'll export to HEIF for web sharing.




Mar 05, 2021 at 07:57 PM
Eruditass
Offline
• • •
Upload & Sell: Off
p.1 #8 · HEIF vs JPG Image Quality Comparison


It be nice to see some simple gradients, those tend to show a lot of JPG degredation easily. Also, predictable patterns. Here was a good comparison I remember of JPG qualities

http://regex.info/blog/lightroom-goodies/jpeg-quality



Mar 05, 2021 at 08:03 PM
Jesse Evans
Offline
• • • •
Upload & Sell: On
p.1 #9 · HEIF vs JPG Image Quality Comparison


snapsy wrote:
Newer cameras such as the A7s III, A1, and 1DX III support the HEIF format as a newer option vs JPG. HEIF offers support for up to 16-bits per color vs JPG's 8-bits, which means more tonal range. HEIF also uses a more advanced compression algorithm, borrowed from H.265 (HEVC). Lastly, HEIF's container has more flexibility, including support for multiple images and mix of images/video in a single file, metadata transform support so that images can be instructed to crop, rotated, zoom, etc.. non-destructively, and transparency/alpha channel.

I was interested in how the image quality compares to JPG vs the space
...Show more

Unfortunately, without interframe interpolation 4:2:2 is a really large downside for still images in a way it is not for videos.

Regarding the 4:2:2 HEIF being the same / slightly larger than the 4:4:4 image. I can think of a couple explanations, but the most likely is that the encoder is using a hardware path under the hood. Hardware encoders and decoders for h.265 rarely support 4:2:2, only offering 4:4:4 and 4:2:0 support.

It is possible that heif_enc.exe is padding the data up to 4:4:4, so you could end up in the worst of all words situation where you have 4:4:4 from the source image -> 4:2:2 intermediate subsampling -> 4:4:4 padding out the subsampled data before encoding. Does heif_enc expose a difference between hardware and software encoding? If so, I'd expect the software path to use genuine 4:2:2 subsampling and result in a smaller file.



Mar 05, 2021 at 08:51 PM
snapsy
Offline
• • • • • •
Upload & Sell: On
p.1 #10 · HEIF vs JPG Image Quality Comparison


Jesse Evans wrote:
Unfortunately, without interframe interpolation 4:2:2 is a really large downside for still images in a way it is not for videos.

Regarding the 4:2:2 HEIF being the same / slightly larger than the 4:4:4 image. I can think of a couple explanations, but the most likely is that the encoder is using a hardware path under the hood. Hardware encoders and decoders for h.265 rarely support 4:2:2, only offering 4:4:4 and 4:2:0 support.

It is possible that heif_enc.exe is padding the data up to 4:4:4, so you could end up in the worst of all words situation where you have 4:4:4
...Show more

For single-image HEIF files there is only intraframe compression. However, HEIF supports multiple images in a single file and those images can use interframe compression, the same as H.265 video. For example this is useful for burst shooting applications, like on Smartphones. I doubt regular cameras will ever use it though.

I believe the x265 library used by libheif is a software-only encoder. Regarding padding, I had verified the HEIF metadata to make sure the files were properly encoded to the chroma subsampling I specified for each converted image.



Mar 05, 2021 at 09:54 PM
Jesse Evans
Offline
• • • •
Upload & Sell: On
p.1 #11 · HEIF vs JPG Image Quality Comparison


snapsy wrote:
For single-image HEIF files there is only intraframe compression. However, HEIF supports multiple images in a single file and those images can use interframe compression, the same as H.265 video. For example this is useful for burst shooting applications, like on Smartphones. I doubt regular cameras will ever use it though.

I believe the x265 library used by libheif is a software-only encoder. Regarding padding, I had verified the HEIF metadata to make sure the files were properly encoded to the chroma subsampling I specified for each converted image.


Regarding the interframe comment, this is mostly about motion. When using a single still frame, the missing chroma data lost to subsampling is pretty obvious, at least in some scenarios. It is less obvious in videos, at least with motion in them, since the chroma data moves between frames.

I've got no explanation for why the file ended up bigger if it is a true 4:2:2. Maybe those shapes are more compressible when they are smooth?



Mar 05, 2021 at 10:02 PM
snapsy
Offline
• • • • • •
Upload & Sell: On
p.1 #12 · HEIF vs JPG Image Quality Comparison


Jesse Evans wrote:
Regarding the interframe comment, this is mostly about motion. When using a single still frame, the missing chroma data lost to subsampling is pretty obvious, at least in some scenarios. It is less obvious in videos, at least with motion in them, since the chroma data moves between frames.

I've got no explanation for why the file ended up bigger if it is a true 4:2:2. Maybe those shapes are more compressible when they are smooth?


Agreed about the perceptible difference of stills vs video for chroma subsampling for viewers. Hurts in some post scenarios though, like green-screen work. Yeah, maybe the boundary of those shapes is such that they cross DCT block boundaries in a way that makes them less compressible. But there's also a lot less data in those CbCr color channels at 4:2:2 vs 4:4:4 so not sure.



Mar 05, 2021 at 10:22 PM
snapsy
Offline
• • • • • •
Upload & Sell: On
p.1 #13 · HEIF vs JPG Image Quality Comparison


Jesse Evans wrote:
I've got no explanation for why the file ended up bigger if it is a true 4:2:2. Maybe those shapes are more compressible when they are smooth?

I went diving through the x265 library documentation and think I figured out why the 4:2:2/4:2:0 is larger. With default settings, the encoder halves the quality of the Cb and Cr planes when 444 is specified, I guess because the higher resolution of 444 can take a lower quality setting (ie, more compression) and so the encoder tries to balance out the effect on the encoded size. If I manually disable the offset then the 444 encoding is larger than the 422.

It's described here:

"In 444, chroma gets twice as much resolution, so halve the quality when psy-rd is enabled. So, when psy-rd is enabled for 444 videos, cbQpOffset and crQpOffset are set to value 6, if they are not explicitly set."



Mar 05, 2021 at 10:50 PM
Jesse Evans
Offline
• • • •
Upload & Sell: On
p.1 #14 · HEIF vs JPG Image Quality Comparison


snapsy wrote:
I went diving through the x265 library documentation and think I figured out why the 4:2:2/4:2:0 is larger. With default settings, the encoder halves the quality of the Cb and Cr planes when 444 is specified, I guess because the higher resolution of 444 can take a lower quality setting (ie, more compression) and so the encoder tries to balance out the effect on the encoded size. If I manually disable the offset then the 444 encoding is larger than the 422.

It's described here:

"In 444, chroma gets twice as much resolution, so halve the quality when psy-rd is enabled. So,
...Show more

Nice deep dive, that's great info.



Mar 05, 2021 at 11:06 PM
EB-1
Offline
• • • • • • •
Upload & Sell: Off
p.1 #15 · HEIF vs JPG Image Quality Comparison


Eruditass wrote:
Perhaps high dynamic range and high color bit depth images. Finally a reasonable lossy format that can support those.

We don't have the issue of people sharing horrible lossy small JPG files as much these days, but HEIF certainly handles those much better.

I won't be shooting HEIF, but maybe eventually I'll export to HEIF for web sharing.



I was referring to image capture. I don't know about the value of posting higher quality on the sociali medias, but I would not want to give out better quality than jpegs.

EBH



Mar 05, 2021 at 11:21 PM
Eruditass
Offline
• • •
Upload & Sell: Off
p.1 #16 · HEIF vs JPG Image Quality Comparison


EB-1 wrote:
I was referring to image capture. I don't know about the value of posting higher quality on the sociali medias, but I would not want to give out better quality than jpegs.

EBH


The first sentence is about image capture. You can't capture high dynamic range outside of RAW right now and I'd imagine that's a major factor for people not shooting JPG. With 16-bits, you can get the full dynamic range and maybe even full white balance adjustment capability.

I still would want the RAW files for more any advanced demosaicing processing or better calibration color profiles that may come along, but there may not be that many other advantages over shooting in HEIF.

As for sharing higher quality images on social media: you don't have to. You can give out equivalent quality and significantly smaller sizes.



Mar 06, 2021 at 12:36 PM
johnctharp
Offline
• • • • •
Upload & Sell: Off
p.1 #17 · HEIF vs JPG Image Quality Comparison


Eruditass wrote:
The first sentence is about image capture. You can't capture high dynamic range outside of RAW right now and I'd imagine that's a major factor for people not shooting JPG. With 16-bits, you can get the full dynamic range and maybe even full white balance adjustment capability.


I started mentally challenging the idea of using a more flexible lossy file instead of raw; I've stopped myself because I indeed shoot raw for two things: post flexibility of things like DR and white balance, and for detail.

For DR and white balance, if absolute detail isn't critical say for web viewing where 8MP / 4k is plenty, a native resolution HEIF capture would probably be enough 99% of the time. Hard to argue against, really.

For detail, where that's desired, it'd be questionable; one would need to have far broader software support than we have today in order to set up a reasonable comparison, since common workflows aren't available.

Eruditass wrote:
I still would want the RAW files for more any advanced demosaicing processing or better calibration color profiles that may come along, but there may not be that many other advantages over shooting in HEIF.


Looking pretty limited really!

Eruditass wrote:
As for sharing higher quality images on social media: you don't have to. You can give out equivalent quality and significantly smaller sizes.


Selecting JPEG is seen as a single-step quality ceiling today; we're going to have to learn where we want our quality to land, presumably to ensure that our work isn't 'stolen'!



Mar 06, 2021 at 07:02 PM





FM Forums | Sony Forum | Join Upload & Sell

    
 

Welcome back
Log in to your account