Saturday, April 20, 2024
HomeMatlabKeep away from Utilizing JPEG for Picture Evaluation » Steve on Picture...

Keep away from Utilizing JPEG for Picture Evaluation » Steve on Picture Processing with MATLAB


I’ve just lately been studying a number of picture processing and picture evaluation questions on MATLAB Solutions. Anybody who does the identical will rapidly come throughout feedback and solutions posted by the prolific Picture Analyst, a MATLAB Solutions MVP who has posted an astounding 34,600+ solutions within the final 11 years.

I all the time benefit from the facet commentary that I typically discover in these solutions. For instance, I got here throughout this code remark in a single reply:

% This can be a horrible picture. NEVER use JPG format

% for picture evaluation. Use PNG, TIFF, or BMP as an alternative.

As we speak, I wish to take the chance to endorse this assertion and to elaborate on it a bit. Why will we not love JPEG information for picture evaluation?

The reason being that JPEG is a lossy picture compression format. Lossy compression strategies obtain substantial discount in file measurement through the use of “inexact approximations and partial knowledge discarding to signify the content material.” With JPEG compression, roughly talking, pixels are grouped into blocks, after which the pixel knowledge in every block is quantized and partially discarded. The strategy is known as lossy as a result of you may’t get the precise authentic picture pixel knowledge again from a JPEG file; info has been misplaced.
I’ve written about lossy vs. lossless compression earlier than; see my 02-Might-2013 put up.

Often, this type of compression is appropriate for viewing images as a result of the compression technique exploits properties of human visible notion in order that the data loss is comparatively imperceptible. In picture evaluation functions, although, if you end up attempting to routinely detect or measure issues, the pixel knowledge imperfections within the JPEG file might mess it up.

Let me present you a few completely different variations of this image:

IMG_6129-reduced-size.png

The unique image was shot in RAW mode (which is lossless) and saved as a 4032×3024 PNG file, with a file measurement of 23 MB.

Here’s a extremely magnified view of the middle of the image. You’ll be able to see the person pixels.

lossless-magnified.png

I created a JPEG model of this file with a file measurement of solely about 1 MB. In case you take a look at all the image, the JPEG model appears to be like like the unique.

However when you take a look at a extremely magnified view, you may see that pixel knowledge has been partially discarded in a block-wise trend.

lossy-magnified.png

You’ll be able to in all probability think about how this may have an effect on object detection and measurement.

So, as Picture Analyst says, stick with lossless codecs equivalent to PNG or TIFF on your picture evaluation functions.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments