Photography Asked by cabbey on June 24, 2021
For example, for a recent conversation about JPEG compression I wanted to compare pixel for pixel what changed between two JPEGs (one with compression level 100, and one with compression level 95).
How do I generate good visual maps of what changed without tedious custom software programing?
Photoshop + Layers FTW. (Yes, you can also use the Gimp, or any other editing software with the same functions.)
Start with your base image, in the case above, I used the jpeg quality 100 image.
In the resulting image, any pixel that is any any way different between the two images will be white. You can adjust it to allow things to be "a little different" by altering the threshold value.
Example showing a LOT of difference between jpeg 92 and 100 from Lightroom.
Example showing no difference at all between 95 and 100.
Not that's just showing a binary "changed or not", what if you wanted more detail on how much it changed, say by color channel?
The brighter the resulting pixels, the more they're different in that color. The downside though is you end up with a lot of grey mud... so sometimes it's easier to just threshold it to see where differences are. That's why I build both and toggle which one is visible.
Correct answer by cabbey on June 24, 2021
If you use Photoshop, here's how I'd do it:
Put the two jpegs in the same psd file, in two separate layers. They should overlap exactly, since their dimensions are the same. (which one goes on top doesn't matter).
Set the layer blending mode to "Difference." You'd see a mostly black result. Depends on the quality difference between the two original layers you may see more or less of the noise.
Answered by Jin on June 24, 2021
In the resulting image the black parts show where the original images are identical and anything lighter shows differences.
Answered by Dan on June 24, 2021
GitHub has some interesting image diff tools built into it on the web, as described here and demonstrated in this demo.
Answered by Fredrik Mörk on June 24, 2021
All image processing packages should make this easy. I'll show you how to do it in Mathematica, if you have access to this system. Mathematica is a programming language, but it's really easy to do these kinds of manipulations, so if you have access to it (e.g. through a university site license), I recommend you give it a go!
First, import the image:
img = Import["http://farm1.staticflickr.com/62/171463865_36ee36f70e.jpg"]
Recompress it using JPEG compression
img2 = ImportString@ExportString[img, "JPEG", "CompressionLevel" -> 0.35]
Now take the difference of pixel values, converting them first to floating point numbers to ensure that negative values are preserved.
diff = ImageSubtract[Image[img, "Real"], Image[img2, "Real"]]
Not much is visible on the difference image (the difference is tiny), and negative values are clipped to black. So let's rescale all values to fill the whole dynamic range (the minimum will be scaled to 0, the maximum to 1):
ImageAdjust[diff]
ImageDifference
gives the absolute difference of the two images, and produces no negative numbers. This is the operation you are more likely to find in image processing packages, especially GUI ones (Photoshop, GIMP).
ImageDifference[img, img2]
We can also take a single RGB channel, for example the red one, and visualize the positive and negative differences using 'opposing' colours:
ArrayPlot[0.5 + ImageData[First@ColorSeparate[diff, "Red"]],
ColorFunction -> "RedGreenSplit", ColorFunctionScaling -> False]
Here's the same thing, with the differences amplified 5 times. The JPEG artefacts are more recognizable now.
ArrayPlot[0.5 + 5 ImageData[First@ColorSeparate[diff, "Red"]],
ColorFunction -> "RedGreenSplit", ColorFunctionScaling -> False]
The advantage of using a programming language is that we can easily automate this and see how the difference changes for "compression levels" between 0.1 and 1.0:
Grid@Partition[Table[
ArrayPlot[
0.5 + ImageData[
First@ColorSeparate[
ImageSubtract[Image[img, "Real"],
Image[ImportString@
ExportString[img, "JPEG", "CompressionLevel" -> c],
"Real"]], "Red"]], ColorFunction -> "RedGreenSplit",
ColorFunctionScaling -> False],
{c, 0.1, 1, 0.1}
], 5]
Answered by Szabolcs on June 24, 2021
You can use Imagemagick command line tools.
composite imagesrc1.jpg imagesrc2.jpg -compose difference diffs.jpg
will provide the absolute value of differences for each RGB channel.
Answered by mikael on June 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP