Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Choosing Better-Quality JPEG Images With Software?

timothy posted about 5 years ago | from the on-the-tip-of-my-script dept.

Graphics 291

kpoole55 writes "I've been googling for an answer to a question and I'm not making much progress. The problem is image collections, and finding the better of near-duplicate images. There are many programs, free and costly, CLI or GUI oriented, for finding visually similar images — but I'm looking for a next step in the process. It's known that saving the same source image in JPEG format at different quality levels produces different images, the one at the lower quality having more JPEG artifacts. I've been trying to find a method to compare two visually similar JPEG images and select the one with the fewest JPEG artifacts (or the one with the most JPEG artifacts, either will serve.) I also suspect that this is going to be one of those 'Well, of course, how else would you do it? It's so simple.' moments."

cancel ×

291 comments

AI problem? (1)

darpo (5213) | about 5 years ago | (#28723509)

Unfortunately, I think you may find that it will simply require a human-level brain. I'd be really impressed with software that said, "Yep, this image just *looks* better to me." Unless, of course, JPG artifacts are systematic and consistent across images, which could well be.

Re:AI problem? (0)

Anonymous Coward | about 5 years ago | (#28723589)

Or you could just check the compression and resolution...

Re:AI problem? (1)

sarbrot (1024257) | about 5 years ago | (#28724239)

yes, that was my first thought as well, compare filesize, dimensions and EXIF (if available). Filesize and dimensions alone should give you a factor that could be used well although there might be edge-cases where files are mislabeled as JPEG when they are in fact bmp or whatever. You should verify them by probing the file header as well

Re:AI problem? (3, Interesting)

Robotbeat (461248) | about 5 years ago | (#28723591)

...it will simply require a human-level brain.

How about Amazon's Mechanical Turk service?
https://www.mturk.com/ [mturk.com]

Re:AI problem? (2, Funny)

eikonoklastes (530797) | about 5 years ago | (#28723949)

Well, of course, how else would you do it? It's so simple.

Re:AI problem? (-1, Offtopic)

Anonymous Coward | about 5 years ago | (#28724065)

Hi,

I'm one of those idiots who worked for Tucker on his movie. I won't say what department, but it is considered "crew". I'd like to address some things about him not coming to Shreveport.

1) I've worked on 17 films in the last 2 years. I've worked for numerous producers, but this is the God's honest truth: Tucker was never really a producer. His role on the film was basically "creative", although he tended to try and get his fingers into everything. I've never once seen one person have less respect on a film set than Tucker Max. After a few days of having Tucker tell the crew how to do their jobs we had a long talk with Sean. We were told that we didn't have to listen to him because he was irrelevent on the set. This was the main producer of the movie telling us this, so we listened.

It drove Tucker even more nuts when he would tell the camera crew to do this or the hair/makeup crew to do something his way and we would just say "okay" and go about doing our jobs. If he ever started getting angry, we would tell him to talk to Sean. I don't think he ever got it as this lasted the whole entire film, but it was funny watching him get frustrated. He really thought he was the boss, and in reality he was the equal to some rich kid whose dad was paying people to play with him.

2) Tucker hit on a number of crew members, none of whom wanted anything to do with him. Mostly he fucked a few skanky locals, but that's about it. People are less impressed by a guy like Tucker Max when you've just had the cast and crew of W. in your town.

3) The cast and crew contacted the producers of the movie to see if it was possible to have a cast/crew showing of the movie. When emailed to Tucker, he said something along the lines of "yeah, pay 30 dollars each". Now, I have worked on many films, all of which have come back to Shreveport to show the cast and crew the film we all worked on. We didn't ask Tucker for him to come down with his freak show. We simply asked if we could get a copy of the movie to show to the people who helped make the film possible. That's when we saw the true Tucker Max for what he is: a mean spirited dick. A guy who acts all gracious when he has to, but the second he doesn't need to be nice, he becomes his natural self. If I were Sean, I'd be embarrassed. Sean and Darko will never be able to do another film in Louisiana (we're very tight down here), I'd say Tucker too, but come on, his script was easily one of the worst movies I've ever worked on (and I've done films with 'Part 5' in the title). We know we'll never see another Tucker Max movie.

4) During the actual filming, it was difficult to keep a straight face. First, the dialogue was TERRIBLE, and as nice as Matt, Jesse and Jeff were, they weren't going to make these bad lines sound good. There were times when even Bob Gosse would roll his eyes at some of the garbage lines that actors were forced to say. This infuriated Tucker even more and it ended up costing us time.

5) Tucker would go around the set and ask us questions like "isn't this the best movie you've ever worked on?" or "what's it like working for a genius?" A lot of the crew would just laugh it off, but by day 5 or 6 we realized that he was serious. Finally a couple of us would say stuff like "this is the most brilliant thing I've ever seen on film" and then would see their words on his stupid ass movie blog the next day. We would read it and laugh at Tucker behind his back.

Anyway, there's a lot more to it, but I just wanted to vent to a bunch of people who aren't his fans, because you can add the entire film community of Shreveport to your ranks as well as anybody who comes into contact with him.

Thanks for listening.

Re:AI problem? (1)

Xenographic (557057) | about 5 years ago | (#28724261)

> How about Amazon's Mechanical Turk service?

He might not want everyone looking at his porn collection?

Also, you'd have to scan every pair of images for dupes, which changes the complexity from N to N*log(N). Moreover, that relies on humans and some people have no idea which image is higher quality. Not everyone even understands what a compression artifact is. Such people won't give you useful answers.

In his situation, I'd probably run the dupe finder program, then examine all the duplicates personally. There can't be *that* many... right?

Re:AI problem? (0)

Anonymous Coward | about 5 years ago | (#28723595)

Use a neural network. You can train the network by presenting it with high-quality photos, and their deteriorated versions.

Re:AI problem? (4, Funny)

lunchlady55 (471982) | about 5 years ago | (#28723745)

Oh sure, it starts out innocently enough - pick the better image. Next thing you know Skynet's decided that it's the better LIFE-FORM.

AI - JUST SAY NO!

Brought to you by the Coalition for Human Survival (C) Aug. 29, 1997

Re:AI problem? (0)

Anonymous Coward | about 5 years ago | (#28723911)

I'd say: do it while it is still legal.

Re:AI problem? (2, Insightful)

nametaken (610866) | about 5 years ago | (#28724025)

You're right, it needs to be done by humans to be sure.

Amazon's Mechanical Turk should do the trick.

https://www.mturk.com/mturk/welcome [mturk.com]

Re:AI problem? (-1, Troll)

Anonymous Coward | about 5 years ago | (#28724073)

a mechanical turk? aren't turks dune coons? who would want a mechanical dune coon? the biological ones are fanatical enough

Re:AI problem? (-1, Troll)

sbeckstead (555647) | about 5 years ago | (#28724169)

Actually no you imbecile. You probably wouldn't recognize which bathroom you should use 2 out of 3 times either.

Re:AI problem? (5, Interesting)

CajunArson (465943) | about 5 years ago | (#28724061)

I don't know about "quality", but frankly it shouldn't be too hard to compare similar images just by doing simple mathematical analysis on the results. I'm only vaguely familiar with image compression, but if a "worse" JPEG image is more blocky, would it be possible to run edge detection to find the most clearly defined blocks that indicates a particular picture is producing "worse" results? That's just one idea, I'm sure people who know the compression better can name many other properties that could easily be measured automatically.
What a computer can't do is tell you if the image is subjectively worse, unless the same metric that the human uses to subjectively judge a picture happens to match the algorithm the computer is using, and even then it could vary by picture to picture. For example, a highly colorful picture might hide the artifacting much better than a picture that features lots of text. While the "blockiness" would be the same mathematically, the subjective human viewing it will notice the artifacts in the text much more.

Re:AI problem? (2, Insightful)

CajunArson (465943) | about 5 years ago | (#28724175)

And to reply to myself.. several other posters have noted that taking the DCT of the compression blocks in the image will give information on how highly compressed the image is... there's one example.

Easy (3, Interesting)

Anonymous Coward | about 5 years ago | (#28723511)

Paste both images in your image editor of choice, one layer on top of each other, apply a difference/subtraction filter.

Re:Easy (3, Insightful)

Random Destruction (866027) | about 5 years ago | (#28724265)

Ok, so you know how two images differ. Which one is closer to the original? You don't know, because you don't have the original to compare.

File size (2, Insightful)

Tanman (90298) | about 5 years ago | (#28723521)

it is lossy compression, after all . . .

Re:File size (0)

Anonymous Coward | about 5 years ago | (#28723587)

Assuming, of course, that the resolution and aspect ratio are the same.

Re:File size (4, Informative)

Robotbeat (461248) | about 5 years ago | (#28723651)

File size doesn't tell you everything about quality.

For instance, if you save an image as a JPEG vs. first saving as a dithered GIF and _then_ saving as JPEG, then the second one will have much worse actual quality, even if it has the same filesize (it may well have worse quality AND have a larger file size).

Re:File size (2, Interesting)

Vectronic (1221470) | about 5 years ago | (#28723981)

Also, stuff like Photoshop, will insert a bunch of meta/exif-bullshit but something like Paint, doesn't... it's usually only about 2 to 3kb, but it's still tainting your results if you are going by size alone.

Re:File size (1, Informative)

Anonymous Coward | about 5 years ago | (#28724111)

actually one of the meta values that is stored is a quality indicator.

Re:File size (0)

Anonymous Coward | about 5 years ago | (#28724033)

Except the guy didn't ask about any of that--all he asked about was jpeg artifacts.

Re:File size (3, Insightful)

teko_teko (653164) | about 5 years ago | (#28723667)

File size may not be accurate if it has been converted multiple times at different quality, or if the source is actually lower quality.

The only way to properly compare is if you have the original as the control.

If you compare between 2 different JPEG quality images, the program won't know which parts are the artifacts. You still have to decide yourself...

Re:File size (1)

richardkelleher (1184251) | about 5 years ago | (#28724029)

If you had a database with say, 100k original images, plus each of those images saved with various levels of compression. Then scan through the files looking for differences between the known higher and lower quality images building a database of what "artifacts" look like. You could then use the database of "artifacts" that occur most frenquently to scan unknown images for matches. After visually reviewing the "artifacts" found in a thousand or so unknown images for validity (is it really something that lowers the quality of the image), you can determine if this method is valid. If determined to be valid, just bounce images off the database of known "artifacts" and rate them for image quality on some scale. The ones with the highest (or lowest depending on the design of the scale) is the better image.

Now, go write that grant (I'm guessing DOD would be interested in funding something like this), put together a staff of 10 or so (20 if you use undergrads) to build and visually analyze the database. Write some analysis software and have a field day.

Oh, by the way, I get 5% of the grant amount as consultant on the initial project design... :-)

Re:File size (3, Insightful)

Anonymous Coward | about 5 years ago | (#28723707)

File size doesn't tell you anything. If I take a picture with a bunch of noise (eg. poor lighting) in it then it will not compress as well. If I take the same picture with perfect lighting it might be higher quality but smaller file size.

Why this is modded up, I don't know. Too many morons out there.

Re:File size (1)

lymond01 (314120) | about 5 years ago | (#28723967)

I sort of had the impression the person was talking about the exact same picture, saved from the original to two different qualities of JPEG. If he were trying to tell the difference between the amount of JPEG artifacts in two different pictures, I imagine he would get inconsistent results, given many trials, for the reasons you say.

I suppose he could have meant something different than what he said, but there aren't too many politicians trolling slashdot, I'd guess.

Re:File size (1)

PitaBred (632671) | about 5 years ago | (#28724137)

But if they're duplicate pictures (some kind of matching heuristic), then file size most certainly IS appropriate. You're starting from the same point, choosing the result with less lost during compression, and therefore larger, would be quite logical.

Re:File size (0)

Anonymous Coward | about 5 years ago | (#28723789)

That's a good first order approximation, but if you're collecting your images from the internet you'll find that sometimes someone will save a low-quality jpeg image at higher quality. Some ancient browsers used to save all images as bmps, then that image might get converted to a jpeg later, using a quality setting that doesn't match the original. The artifacts will still be there but the file size will not reflect that.

Re:File size (4, Informative)

Shikaku (1129753) | about 5 years ago | (#28723825)

http://linux.maruhn.com/sec/jpegoptim.html [maruhn.com]

No. You can compress JPEG lossless.

Re:File size (0)

Anonymous Coward | about 5 years ago | (#28723919)

Informative? Slashdot's standards really have been dropping lately. This utility you linked to appears to perform some sort of additional lossless optimization of a JPEG file. However, THE ORIGINAL JPEG FILE WAS ALREADY COMPRESSED IN A LOSSLESS WAY, and furthermore, THERE IS NO LOSSLESS JPEG. PERIOD.

Re:File size (5, Informative)

Score Whore (32328) | about 5 years ago | (#28724123)

...THERE IS NO LOSSLESS JPEG. PERIOD.

Except for Lossless JPEG [wikipedia.org] standardized in 1993. But other than that, no there is no lossless jpeg.

Re:File size (0)

Anonymous Coward | about 5 years ago | (#28724271)

Err, that should read "the original jpeg file was already compressed in a lossy way."

Re:File size (1)

kernelphr34k (1179539) | about 5 years ago | (#28724141)

jpeg is a lossless format anyways... JPEG suck if you want to keep quality.. Everytime you open and save the image it looses quality. Use a PNG, or TIF for a better quality image that you can open and save many times without loosing quality.

Admit your a huge faggot (-1, Troll)

Anonymous Coward | about 5 years ago | (#28723537)

Then rape your face.

I'm not an expert (1)

Flimzy (657419) | about 5 years ago | (#28723539)

But what if you saved both images in an uncompressed format (bmp?), then compressed them both using a lossless format (gzip?), and compared the file sizes...

Do it with a bunch of images, and I expect you'll discover that the low-quality-gzipped image will be smaller than the high-quality-gzipped image...

Maybe? *shrug*

Re:I'm not an expert (1)

gurps_npc (621217) | about 5 years ago | (#28723579)

I agree that this would probably be the simplest method. Note, I wonder if something as simple as examining the file size of the jpeg would be good enough for most cases.

Re:I'm not an expert (0)

Anonymous Coward | about 5 years ago | (#28724193)

"I agree that this would probably be the simplest method."

Or he could just, you know, save it as an LZW or ZIP compressed tiff directly, rather than going from bitmap to zip. That would be simpler.

Not that that method is foolproof. Jpeg artifacting on a low-detail/high contrast image (like a checkerboard pattern) is spurious detail, and would result in a larger file size, whereas an unartifacted copy of the image would make a very small file.

Re:I'm not an expert (1)

Bill, Shooter of Bul (629286) | about 5 years ago | (#28723715)

Good idea. I'm also not an expert. Though, I would think there is a limit to how well this would work. If it were cell shaded to some extent, it might look better than a lossy jpg, but compress to a smaller size. The question is if there would be any point in between where loss of information would actually result in better image quality.

Imagine a chess board is in the image. If an image is sort of lossy, the lines between the black and white might get a little blurred with some black running into some white and visa versa. If you just made the entire board to be a flat gray that averaged the two, it might look better to a human, even if that isn't what the original image was.

Re:I'm not an expert (1)

sznupi (719324) | about 5 years ago | (#28723929)

I'm also not an expert, but I suspect it might work in the other direction far too often.

Perhaps artifacts of low-quality jpeg images, embedded in simple stream of bmp, could look more like noise to general purpose compressor; more than "natural" photographs with gradual gradients.

And random noise is incompressible.

File Size. (0)

Anonymous Coward | about 5 years ago | (#28723543)

Larger file size should give a rough hint if both images are the same format (i.e. JPEG). But you've probably already thought of that.

Of course, there ought to be better ways...

File size or density? (1)

Durandal64 (658649) | about 5 years ago | (#28723555)

Have you tried just comparing the files' sizes with respect to the images' dimensions? It'll vary from encoder to encoder, but higher-quality JPEGs will be larger than lower-quality ones. You could just use the number of pixels in the picture and the file size to obtain a rough approximation of "quality per pixel" and choose the image with the higher value. It won't be perfect, but it's a lot easier than trying to pick out JPEG artifacts.

Also, the number of artifacts doesn't tell the full story. One image may have more artifacts, but those artifacts may all exist in the background parts of the image, while the foreground is less blocky. It's a choice each encoder makes.

Re:File size or density? (1)

PCM2 (4486) | about 5 years ago | (#28724027)

And BTW, isn't this what most of us do already when we're searching Google Images?

the solution is simple (-1, Flamebait)

Anonymous Coward | about 5 years ago | (#28723563)

I would have sex with a mare.

Re:the solution is simple (-1, Offtopic)

Anonymous Coward | about 5 years ago | (#28723891)

A friend of a friend had sex with a mare, but it didn't solve my image comparison problem. His image problem. His.

Share your suggestions (1)

gehrehmee (16338) | about 5 years ago | (#28723565)

Given a set a pictures, it would be really nice to see them grouped by "these are several pictures of the same scene/object/subject". This is a tool I'm not aware of yet, and I'd love to hear what open-source tools people are using.

As a next step, it would be neat to pick out the one that's most in focus...

Re:Share your suggestions (1)

Chabo (880571) | about 5 years ago | (#28723965)

I saw a piece of software that does something similar to what you're talking about; recently I watched James May's Big Ideas [wikipedia.org] , they showed a camera that you wear around to create a lifelog [wikipedia.org] .

The camera took photos every 30 seconds or so, and the software was able to divide sets of photos into "events"; it distinguished between the time the wearer was in the kitchen making breakfast, and when they sat at their computer typing up an article, for instance. I imagine that someone's created similar software for public use, then.

tineye? (1)

E IS mC(Square) (721736) | about 5 years ago | (#28724113)

Check out Tineye - http://tineye.com/faq [tineye.com]

It does not do exactly what above post suggests, but it partially does what submitter asked (finding similar images on the net).

The Human Eye (0)

Anonymous Coward | about 5 years ago | (#28723567)

Artifacts are something visible to us - they mean nothing to software. It doesn't know wether the pixels are intentionally colored that way (ie, detail) or colored that way through some compression process at some point in time (ie, artifacts) or something else (eg, ditherting, color depth, banding, etc). If two images are compressed at vastly different ratios, you'll be able to tell easily. Otherwise, they're probably both at a default 90% and if you can't tell the difference, whats the problem?

Re:The Human Eye (1)

jhfry (829244) | about 5 years ago | (#28724105)

Software is well suited to detecting patterns, including patterns that might appear as distracting artifacts in an image. Just because subjectively the pictures are both equally similar to the original, doesn't mean that they are mathematically similar.

I can imagine a method for comparing two images to an original image and scoring the two based upon how similar they are to the original while detecting and deducting for distracting compression artifacts. Ironically this method would be very similar to the JPEG compression algorithm itself, as it tries to make decisions with regard to subjective ideas and artifact reduction (dark areas are reduced in complexity, noise is blurred, etc because most people don't perceive these changes as readily as other areas of detail loss.)

Perhaps using a subjective comparison scoring mechanism you could train this algorithm to favor your individual taste during is compare, perhaps you could even add this capability to a JPEG compression tool so your JPEGs can reflect your individual perception better.

For example, I can accept more blurring, but banding in solid color areas are very distracting to me, while some people would rather keep detail that might be smoothed out and they might tolerate a bit of banding in large fields of color.

Well... (0)

Anonymous Coward | about 5 years ago | (#28723569)

If you want to know which image has more artefacts, it would still be hard to tell what is an artefact and whats supposed to be part of the image.

If you just want to know which is more compressed.. dont jpeg images store the compression ratio used the last time they were saved? It should be in the header somewhere.

Choose the largest file size. (-1, Redundant)

Anonymous Coward | about 5 years ago | (#28723571)

Not perfect but it should be right in most cases.

Try compressing both further (2, Insightful)

Ed Avis (5917) | about 5 years ago | (#28723575)

I suppose you could recompress both images as JPEG with various quality settings, then do a pixel-by-pixel comparison computing a difference measure between each of the two source images and its recompressed version. Presumably, the one with more JPEG artefacts to start with will be more similar to its compressed version, at a certain key level of compression. This relies on your compression program generating the same kind of artefacts as the one used to make the images, but I suppose that cjpeg with the default settings has a good chance of working.

Failing that, just take the larger (in bytes) of the two JPEG files...

Re:Try compressing both further (1)

JPortal (857107) | about 5 years ago | (#28723731)

I think you're onto something. It's not perfect, but all other solutions require (1) near-human AI, (2) the original file as a control, or (3) comparing filesize which may not be accurate, as described in other comments.

Filesize is a hint (1)

democrates (1055572) | about 5 years ago | (#28723585)

less compression = bigger file

Re:Filesize is a hint (4, Informative)

thethibs (882667) | about 5 years ago | (#28723887)

More Noise = Less Compression

Re:Filesize is a hint (1)

democrates (1055572) | about 5 years ago | (#28723995)

Lol, noise is indeed a poor word for information loss.

Requires original image in loss-less form (1)

xquark (649804) | about 5 years ago | (#28723617)

or else the problem is not truly resolvable. The other way is to
assume all the similar images come from the same source, if so then
its as simple as looking at the compression level in the file format
and the various levels of scaling applied to the lossy images.

I believe I've heard of something similar... (0)

Anonymous Coward | about 5 years ago | (#28723619)

You save both images at a lower JPG quality and you test which one changed more (across all its pixels; remember to factor in the relative importance of various types of changes) from its original state to its new lower-quality state. The image that changed more was more dependent on the original JPG quality setting so it had more information, detail, etc..

Artificial, artificial intelligence (1)

Ant2 (252143) | about 5 years ago | (#28723621)

Take a look at Amazon's Mechanical Turk offering. (www.mturk.com) You create "hits" either through their website or API and real humans complete the tasks. This one would be simple, some two (or more) images to the worker and have them select the one with the best quality. You can even pre-screen workers by having them complete a qualification test. You could get all your images sorted out for a penny or two a piece.

ImageMagick can give you EXIF data. (4, Informative)

bcrowell (177657) | about 5 years ago | (#28723623)

The ImageMagick package includes a command called identify, which can read the EXIF data in the JPEG file. You can use it like this:

identify -verbose creek.jpg | grep Quality

In my example, it gave " Quality: 94".

This will not work on very old cameras (from ca. 2002 or earlier?), because they don't have EXIF data. This is different info than you'd get by just comparing file sizes. The JPEG quality setting is not the only factor that can influence file size. File size can depend on resolution, JPEG quality, and other manipulations such as blurring or sharpening, adjusting brightness levels, etc.

Re:ImageMagick can give you EXIF data. (1)

ss122_ry (812631) | about 5 years ago | (#28723939)

Is it guaranteed that, of two visually similar jpegs, the one with a higher quality has less artifacts? I think not.

Re:ImageMagick can give you EXIF data. (1)

Jane Q. Public (1010737) | about 5 years ago | (#28724125)

No guarantee, but the probability is extremely high. If you have two files of the same dimensions that are visually similar (i.e., different versions of the same picture), then the one with the higher dpi rating (which is not directly related to dimension in JPEG) and better quality (lower compression) as shown by EXIF data is almost certainly going to be the one with fewer artifacts in the real world. Of course it is possible to create situations in which that is not so, but they don't usually happen accidentally.

But as someone else mentioned, EXIF data is not always present. Some programs do not generate EXIF data when they save the file, for example.

Re:ImageMagick can give you EXIF data. (3, Informative)

DotDotSlasher (675502) | about 5 years ago | (#28724167)

imagemagick can also compare two images, and tell you how different they are. That is -- quantify the differences by returning a floating point number or two (PSNR, RMSE) in a way that a more-compressed JPEG image will return a correspondingly different floating point value. I know the question concerns two JPEG-compressed images, but if you do have an original image -- and you want to test which is closest to the original, ImageMagick can do that. Use the ImageMagick compare function.
See http://www.imagemagick.org/script/compare.php [imagemagick.org]

Also, [[www.gimp.org]] is able to look at an image and approximate what JPEG compression quality setting was used, and use that same quality setting to save an output JPEG copy of the image. So -- they have some algorithm inside of their application which takes an image and returns (a good guess of) the corresponding jpeg quality value.
Of course, this does not help you if the image was saved with a lousy JPEG quality value, like 10/100, and later saved at a much higher value, like 98/100. Since the algorithm only sees the last image, it would tell you the quality value is 98/100, even though the contents of the image would indicate the results of 10/100 compression, because of multi-generational lossy compression.

Translation: Please help me with my porn... (5, Insightful)

Chyeld (713439) | about 5 years ago | (#28723627)

Dear Slashdot,

Recently I checked my porn drive and realized that I have over 50 gigibytes of jpg quality porn collected. Unfortunately, I've noticed that a good portion of these are all the same picture of Natlie Portman eating hot grits. Could you please point me to a free program that will allow me to find the highest resolution, best quality version of this picture from my collection and delete the rest?

Many Thanks!

Found it a while ago (5, Informative)

sco08y (615665) | about 5 years ago | (#28723749)

I mean, you don't want second rate pictures in your pr0n stash?

I had problems building it back then, let alone writing the scripts for it and the hassle of figuring out which images were duplicates, but this utility [schmorp.de] seems to fit the bill.

Re:Translation: Please help me with my porn... (1)

Pointy_Hair (133077) | about 5 years ago | (#28723903)

... and I've been wanking to it so often I actually -have- gone blind now and can't tell the versions apart, even on my new widescreen monitor!

jpeg quality != image quality (1)

johnrpenner (40054) | about 5 years ago | (#28723639)

all things the same, jpeg quality gives a good index to the quality of the image,
but it can be just as true that a lower jpeg quality image might be a better quality image.

for example, two images: the first image might be scanned off a badly faded
colour photocopy of a famous painting - it is saved at 300 dpi - approximately
2800 x 1200 pixels, and the jpeg quality set at 12 -- the second image is a
well lit photograph of the original painting, scanned on a scitex scanner,
and brought in as a tiff original -- all high end, but then they res it down to
only 1600 x 900 pixels, say at 200 dpi, and saved at a jpeg quality of 8.

well, in such a case, most software based on the assumption
that jpeg quality = image quality would auto-pick the worser image. :-(

handy index variable to have tho - could provide a resolution / jpeg quality
metric in the google image searches... :-)

all the best
john penner

Contrast (0, Redundant)

clem.dickey (102292) | about 5 years ago | (#28723645)

An image with more contrast (greater average difference between adjacent pixels) probably has more detail. But compressability, as has already been noted, is probably just as good a measure.

use the JPEG underlying details (2, Insightful)

cellurl (906920) | about 5 years ago | (#28723657)

To make a JPEG, you cut it into blocks, run the DCT [wikipedia.org] on each block and mess with the 4:2:2 color formula and pkzip the pieces... That said, I would think measuring the number of blocks would be related to number of artifacts... In my barbaric approach to engineering, (assuming there is no other suggested way on slashdot), I would get the source code to the JPEG encoder/decoder and print out statistics (number of blocks, block size) of each image...

It's easy (5, Insightful)

Anonymous Coward | about 5 years ago | (#28723673)

Run the DCT and check how much it's been quantized. The higher the greatest common factor, the more it has been compressed.

Alternatively, check the raw data file size.

quantization tables (3, Insightful)

angryargus (559948) | about 5 years ago | (#28723683)

Others have mentioned file size, but another good approach is to look at the quantization tables in the image as an overall quality factor. E.g., JPEG over RTP (RFC 2435) uses a quantization factor to represent the actual tables, and the value of 'Q' generally maps to quality of the image. Wikipedia's doc on JPEG has a less technical discussion of the topic, although the Q it uses is probably different from the example RFC.

iterate over jpeg quality setting (0)

Anonymous Coward | about 5 years ago | (#28723685)

When you save a JPEG, you usually choose a quality setting 0-100. I'm not sure if the effect of that is standard, but this should have reasonable results either way: try saving both images at 100, then progressively decrease the quality level until the image changes because additional artifacts are being introduced. This way, you can experimentally determine the quality setting of each image, and just choose the higher of the two. Alternatively, if that quality setting is available in the metadata somewhere, just read that.

Measure sharpness? (4, Interesting)

Anonymous Coward | about 5 years ago | (#28723693)

Compute the root-mean-square difference between the original image and a gaussian-blurred version?
JPEG tends to soften details and reduce areas of sharp contrast, so the sharper result will probably
be better quality. This is similar to the PSNR metric for image quality.

Bonus: very fast, and can be done by convolution, which optimizes very efficiently.

Re:Measure sharpness? (1)

PCM2 (4486) | about 5 years ago | (#28723985)

But this method requires a copy of the original -- or failing that, you'd need to already know which of the JPEGs is the highest quality, which defeats the purpose.

Re:Measure sharpness? (1)

uhmmmm (512629) | about 5 years ago | (#28724223)

No it doesn't. This method has another problem (see my replies to it), but other than that, it could work. He's suggesting that to each copy of the image, you look at the difference between that copy and a blurred version of it. This will give you an idea of how sharp that copy is. And since JPEG throws out high frequency information first, resulting in blurring, it would appear at first glance that the sharper image should be the higher quality one.

As I said in another comment though, JPEG operates on blocks, and especially at very low qualities, you get sharp edges between each block. So the assumption that sharp image == high quality is not really valid.

Re:Measure sharpness? (3, Insightful)

uhmmmm (512629) | about 5 years ago | (#28724109)

Even faster is look at the DCT coefficients in the file itself. Doesn't even require decoding - JPEG compression works by quantizing the coefficients more heavily for higher compression rates, and particularly for the high frequency coefficients. If more high frequency coefficients are zero, it's been quantized more heavily, and is lower quality.

Now, it's not foolproof. If one copy went through some intermediate processing (color dithering or something) before the final JPEG version was saved, it may have lost quality in places not accounted for by this method. Comparing quality of two differently-sized images is also not as straightforward either.

Re:Measure sharpness? (1)

uhmmmm (512629) | about 5 years ago | (#28724171)

Also, JPEG works on blocks. While it's true that JPEG gets rid of high frequency details first (and thus results in blurring), this is only useful within each block. You can have high contrast areas at the edge of each block, and this is actually often some of the most annoying artifacting in images compressed at very low quality. So just because it has sharp edges doesn't mean it's high quality.

DCT (4, Informative)

tomz16 (992375) | about 5 years ago | (#28723695)

Just look at the manner in which JPEGs are encoded for your answer!

Take the DCT (discrete cosine transform) of blocks of pixels throughout the image. Examine the frequency content of the each of these blocks and determine the amount of spatial frequency suppression. This will correlate with the quality factor used during compression!

   

Re:DCT (3, Insightful)

mikenap (1258526) | about 5 years ago | (#28724143)

This seems to me the best suggestion, and there's a simple visual way to accomplish it! The hardest hit part of the image is going to be the chroma information, which your eye normally has reduced resolution sensitivity for in a normal scene. To overcome this, load your JPEGs into your favorite image editor and crank the saturation to the max(this throws away the luminance data). Now the JPEG artifacts in the chroma information will HIT YOU IN THE FACE, even in images that seemed rather clean before. Pick the least blocky of the two, and there you go!

use a "difference matte" (4, Informative)

Anonymous Coward | about 5 years ago | (#28723719)

load up both images in adobe after effects or some other image compositing program and apply a "difference matte"

Any differences in pixel values between the two images will show up as black on a white background or vise versa...

adam
BOXXlabs

Re:use a "difference matte" (2, Insightful)

uhmmmm (512629) | about 5 years ago | (#28724241)

So, that will show you which parts differ. How do you tell which is higher quality? Sure, you can probably do it by eye. But it sounds like the poster wants a fully automated method.

find the edges? but size is useful and easy? (1)

with a 'c' (1260048) | about 5 years ago | (#28723721)

Assuming you can find similar images programmatically you can probably use size to get a good guess. Alternately I know there are algorithms to find edges. Edges are where most jpeg artifacts show up. If you could then look at the gradient from the edges smooth ones will likely be the better image.

Try ThumbsPlus (3, Informative)

Anonymous Coward | about 5 years ago | (#28723729)

ThumbsPlus is an image management tool. It has a feature called "find similar" that should do what you want as far as identifying to pictures that are the same except for the compression level. Once the similar picture is found you can use ThumbsPlus to look at the file sizes and see which one is bigger.

The most obvious artefects... (1)

91degrees (207121) | about 5 years ago | (#28723753)

Seems that if I really overcompress a JPEG, the main problems are at the edges of the blocks. This is not really unexpected.

So a simple first pass would be to apply a simple edge detector and look for discontinuities at the edges of the 8x8 blocks. For an example, just try an edge detector in any decent image editing app on an overcompressed JPEG.

Bits per pixel (1)

Citizen of Earth (569446) | about 5 years ago | (#28723771)

Compute the number of bits per pixel of the image data.

edge detection (0)

Anonymous Coward | about 5 years ago | (#28723779)

use an edge-detection filter. since jpeg artifacts usually present themselves as "smeared out" edges, you may be able to figure out some rule based on the edge-detected image.

image quality measures (4, Informative)

trb (8509) | about 5 years ago | (#28723813)

google (or scholar-google) for Hosaka plots, or image quality measures. Ref:

HOSAKA K., A new picture quality evaluation method.
Proc. International Picture Coding Symposium, Tokyo, Japan, 1986, 17-18.

Check the quantization (1)

PhrostyMcByte (589271) | about 5 years ago | (#28723989)

I remember a Slashdot article of a guy who used JPEG quantization to detect if images were photoshopped... it had an example of a terrorist adding books. Can't find it via google tho.

Re:image quality measures (0)

Anonymous Coward | about 5 years ago | (#28724161)

Any idea where to get hold of that paper? It only pops up as a reference for me.

Neural network! (0)

Anonymous Coward | about 5 years ago | (#28723837)

Compress a bunch of original images with variable quality, noise, etc.

Go through this set of images (where you know which one is "best") and train it to return two booleans, one for match/no-match, another for first better or second better.

Slow to train, but you can use GPGPU for massive speedups.

analyze the picture (-1, Redundant)

Anonymous Coward | about 5 years ago | (#28723885)

Do a two dimensional fast fourier transform, the one with the highest frequency components retained is the better.As the jpeg standard is based on the fourier transform understanding the standard will probable result in a faster solution.

Blur Detection? (2, Informative)

HashDefine (590370) | about 5 years ago | (#28723921)

I wonder if out of focus or blue detection methods will give you a metric which varies with the level of jpeg artifcats, after all the jpeg artifacts should make it more difficult to do things like edge detections etc which are the same the things that made more difficult by blurry and out of focus images

A google search for blur detection should bring up things that you can try, Here [kerrywong.com] is series of posts that to do a good job of explaining some of the work involved

Fourier transform (2, Interesting)

maxwell demon (590494) | about 5 years ago | (#28723931)

Assuming the only quality loss is due to JPEG compression, I guess a fourier transform should give you a hint: I think the worse quality image should have lower amplitude of high frequencies.

Of course, that criterion may be misleading if the image was otherwise modified. For example noise filters will typically reduce high frequencies as well, but you'd generally consider the result superior (otherwise you woldn't have applied the filter).

Well (0)

Anonymous Coward | about 5 years ago | (#28723943)

You could just open the low quality images and save them with a higher quality setting.

Filters (5, Funny)

mypalmike (454265) | about 5 years ago | (#28724045)

First, make a bumpmap of each image. Then, render them onto quads with a light at a 45 degree angle to the surface normal. Run a gaussian blur on each resulting image. Then run a quantize filter, followed by lens flare, solarize, and edge-detect. At this point, the answer will be clear: both images look horrible.

Look for boundries (0)

Anonymous Coward | about 5 years ago | (#28724087)

JPEG compression averages groups of pixels with similar color data inside the JPEG image, but does not weigh that average against nearby pixel groups. You can use this fact to identify JPEG artifacts, even if the edges between artifacts is not visible to human eyes.

EG, in a patch of sky, which has a fairly random, but otherwise uniform distribution of shades of blue, there will emerge "squares" where the averaging algorithm has averaged a pixel group, but did not weigh the average of adjacent groups, resulting in a visually identifiable artifact.

You can gauge the quality of a compressed JPEG image by testing for discrete boundries in areas of similar color values that would nominally contain a random (or smooth gradient with random dither) aggregation of similar color types, and assinging a "Severity" value based on the 'hardness' of the artifact's differnce to it's neighbors.

In other words, in areas that would have originally had a nice "smooth" blending of similar colors, you will end up with blocks of discrete colors that have discernable edges. The severity of artifacting would be determinable by measuring how far discretely unique each artifact block is from it's neighbors, (with caveats to natural boundries- such as sky against tree, etc.)

To evaluate if an edge is a JPEG artifact or not, you should gather the JPEG pixel group size from the JPEG header, then see if your edges form a rectangle that is a multiple of that size.

This way you can tell if the hard edge is an artifact, or if it is the edge of Paris Hilton's nipple (or some other natural edge. Natural edges will very rarely have a mathematically perfect rectangular profile.)

A systematic evaluation of an image would be slow and painful, but would produce a scoring benchmark to rate two arbitrary JPEGs against each other. (Better would, of course, be 2 JPEGS and a lossless PNG-- that way you have the un-averaged data to help identify artifact boundries with, among other things, but that isnt what you asked for.)

different images? (0)

Anonymous Coward | about 5 years ago | (#28724101)

"It's known that saving the same source image in JPEG format at different quality levels produces different images"

news to me.

Automatic JPEG Artifact Removal (4, Interesting)

yet-another-lobbyist (1276848) | about 5 years ago | (#28724165)

For what it's worth: I remember using Paint Shop Pro 9 a few years ago. It has a function called "Removal of JPEG artifacts" (or similar). I remember being surprised how well it worked. I also remember that PSP has quite good functionality for batch processing. So what you could do is use the "remove artifact" function and look at the difference before/after this function. The image with the bigger difference has to be the one of lower quality.
I am not sure if there is a tool that automatically calculates the difference between two images, but this is a task simple enough to be coded in a few lines (given the right libraries are at hand). For each color channel (RGB) of each pixel, you basically just calculate the square of the difference between the two images. Then you add all these numbers up (all pixels, all color channels). The bigger this number is, the bigger the difference between the images.
Maybe not your push-one-button solution, but should be doable. Just my $0.02.

compare against the static baseline. (1)

circusboy (580130) | about 5 years ago | (#28724251)

compare both images against the original, not each other.
count number of pixels different from the original, then calculate max and average difference between either image and the original.

decide which parameter means more to you.

go forward from there.

Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...