Wikipedia:Reference desk/Archives/Computing/2020 June 16

= June 16 =

Detecting JPEG artifacts?
Is there a certain technique, method, or visual rule of thumb that could be used to quickly detect JPEG artifacts on images especially the digital scans or photographic reproductions of a painting? I have been busy on Wikimedia Commons and a few photographers on there told me that is full of artifacts, which I was not really aware of when I first found and compared it to. StellarHalo (talk) 09:14, 16 June 2020 (UTC)


 * There are many techniques, but none of them are very good; because "artifact" is a pretty broad category of subjective judgement calls about a very broad set of objective problems in digital signal processing. Most likely, the best proxy for your purpose will be to look at the JPEG "quality" setting, if it is published in the metadata; but even that parameter is not universally present, nor is it verifiably correct; nor is it easy for us to summarize what exactly the "quality" number even means without diving deep in to the JPEG compression algorithm and several of its commonly-used implementations.
 * Generally, most people are probably looking for subjectively visible artifacts: block discontinuities and ringing are often visually apparent in JPEG files. But there are so many more possible artifacts, with so many root causes, and there is no easy way to summarize them except to refer you to a very heavy book on image signal processing.  One usually begins with Proakis and Manolakis.
 * Here's a published paper from one of my colleagues, which apparently won "Best Paper" at CVPR: Tampering Detection... for digital images, CVPR 2017, which is about as "state-of-the-art" as you will find.
 * And here is a fairly technical introduction to JPEG - written for a non-technical audience - by some very enthusiastic undergraduates.
 * Regrettably, we can't fight every battle, but ... if you become very heavily informed on this topic, you'll probably stop taking the snide comments of photographers (or anyone else, for that matter) very seriously until they can objectively define what they are subjectively seeing. The community of digital photography is full of opinionated people who are less informed about image-quality than they initially appear.
 * In case I need to be more blunt: neither JPEG file is better. These two files are different.  If we had the time, we could write a lengthy book on how these files differ, and if we were so inclined, we could talk about which file any individual one of us prefers; and we could back up our subjective, emotional responses with quantitative technical justifications, tailoring the level of analysis to the audience, who may or may not have formal training in image analysis methods; but the short summary is that neither file is better.  Nobody can truthfully even say that one file is more close to the original, or more authentic, unless they are very cautious in their definitions and the application of those definitions; and - now, this is probably the most heretical thing I will say, but it is equally true -  nobody can even truthfully say that one image has more artifacts than the other until they rigorously define "artifact."
 * Nimur (talk) 15:27, 16 June 2020 (UTC)
 * To clarify, I was not implying that the second smaller image (the one being used on Wikipedia) does itself not have artifacts. I uploaded the first larger image to Wikimedia Commons and nominated it for Featured Pictures because I prefer its lighting and higher resolution. If I had nominated the second smaller image instead, I believe they would also say that it has artifacts. I apologize if there was a confusion. In any case, while it is unfortunate that there is no quick easy and accurate way to detect artifacts, could you at least tell me whether or not the first image has block discontinuities and ringings since those are, as you said, the most visible types of artifacts? If you could also tell me how to look for them specifically, that would be helpful. StellarHalo (talk) 21:46, 16 June 2020 (UTC)
 * The short answer is, yes: both images contain visible evidence of "artifacts" (residual errors introduced specifically by the JPEG compression algorithm). I spot this kind of thing because I know where to look: I look for expected changes in frequency content, and then I check for quantization: I look across the block boundaries for discontinuities where it ought to be continuous; and I look at the block interiors for uniformity where it ought to to be non-uniform.  I'm imposing my visual perception - this method would be called "using a learned prior" if I were to publish my method of visual-inspection in a scientific journal in this decade.  I also use specialized software - you can approximate it using something like Photoshop or GNU Image Manipulation Program - my software lets me do certain tasks incredibly fast - so that's a cool way to see more pixels under more viewing-conditions per second.  Most days, I happen to look at a lot of pixels per second - probably at least a few thousand (or maybe even a million!  But I jest... I am the slowest part of my image-processing pipeline)... - so, naturally, I have a little bit of experience in this area - it's probably truthful to say that experience matters, so if you like this kind of thing, start looking at more photos more often, and consider using different tools, different conditions, and even different thought-processes.
 * If all these words like "macroblock" and "residue" and "quantization" and "pixel" seem like mindless technobabble drivel, then let me be the first to congratulate you on the start of a many-year journey into the art and science of image signal processing. This stuff is hard - even JPEG, which is almost fifty-year-old technology, is not something that we can properly summarize in under an hour for a non-technical audience.  Have you read and understood the Lossy Data Compression website I linked earlier?  It's about the fastest possible introduction that can be provided without insulting your intelligence.  Take it from me - image-compression is literally the art of providing the most information in the least amount of time, but there are really well-understood theoretical limits to just how much we can squeeze the information before it gets, well, ... lost.  The fine folks over at the Mathworks sell commercial short-courses in image and video processing - you can pay them to teach you everything you need to know, spread over a week or ten, for about the cost of a light-to-medium college education.  There are also lots of free and zero-cost resources: after all, the reference implementation of JPEG is unofficially officially free, as long as you already know what to do with it.
 * Back to our OP's images: both images are pretty mild in terms of plausible, visible JPEG-like compression artifacts, but there are much more significant differences ("artifacts") that probably have no relation whatsoever to the JPEG compression. Have you noticed the color difference between the photos?  To me, this is incredibly obvious; I can speculate wildly about the origin of this artifact, but I will leave that to our readers.
 * But I can't emphasize this strongly enough: perception is incredibly important. If you don't notice the defective pixel, it isn't defective.  Everything from the software and hardware you are using, to the lighting in the room you sit in, to the biology of your eye and your brain in particular, all modulate the way that you perceive these pixels.
 * Nimur (talk) 15:13, 17 June 2020 (UTC)
 * The first picture has seemingly been sharpened to death, the many chalk white pixels are a characteristic symptom and colour nuances are completely lost. I'm sure that the second picture ist much more similar to the original and is also ways more agreable with natural colors, many intermediate nuances and no trace of plaster-white. Of course taste is subjective, and if it is only for personal use as long as they are not aware of its defects so might the OP enjoy the first picture as well, but he should educate theirs eyes a little bit before choosing pictures for the publicum. And yes, as always, the best if not only one 'technique, method, or visual rule of thumb' for detecting artifacts is training, training, training. 2003:F5:6F06:8700:E525:5ACE:97DD:7867 (talk) 16:11, 17 June 2020 (UTC) Marco PB