romankh3 / image-comparison

Published on Maven Central Java Library that compares 2 images with the same sizes and shows the differences visually by drawing rectangles. Some parts of the image can be excluded from the comparison. Can be used for automation QA tests.
https://t.me/romankh3
Apache License 2.0
337 stars 105 forks source link

Add test for images with different jpeg-compression level #138

Closed Hexronimo closed 4 years ago

Hexronimo commented 4 years ago

Hello Roman! Can you, please, add tests for images with different jpeg-compression? I believe many people who often work with jpeg will have this question. When someone made changes in the image in programs like Photoshop or Gimp and save image as jpg file, s/he needs to choose the compression level (good quality and large file weight or visa versa, from 0 to 100%). The compression algorithm makes some changes in pixels of the original image. When compression is near 60-70 quality lowering not much visible for human eyes tho, but still can be tangible for your algorithm even with a 10% sensitivity threshold. So the question is will compression be a problem? Will high compression prevent your library work as expected?

I made some images for 4 tests. Every test is in separate dir which contains an original image that needs to be compared with other 3-4 one by one. Each image has a different quality: original - original with some changes - 60 - 20 - 0 (it's written in the filename). Images in the first dir don't have any 'human-made' difference just compression by itself. And the last test is for text-image, I think it's a very interesting case too. images_for_test.zip

romankh3 commented 4 years ago

Hello, Olga! I think this is a good idea. I'll do it.

Best regards, Roman.

akondas commented 4 years ago

Hello @romankh3 Do you have any idea how to implement this yet?

romankh3 commented 4 years ago

hello, @akondas. I haven't thought about it yet. is it important for you?

akondas commented 4 years ago

Possibly, but more out of curiosity. Because I'm wondering how to deal with it technically.

czw., 21 lis 2019, 16:00 użytkownik Roman Beskrovnyi < notifications@github.com> napisał:

hello, @akondas https://github.com/akondas. I haven't thought about it yet. is it important for you?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/romankh3/image-comparison/issues/138?email_source=notifications&email_token=AB63WLMGJHQ2SK22XVJRYPDQU2PCBA5CNFSM4JK7BLL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE2QMLQ#issuecomment-557123118, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB63WLMDTJIEV7YUI2SJE3DQU2PCBANCNFSM4JK7BLLQ .

romankh3 commented 4 years ago

I’m sure that based on pictures we can research it. Don’t hesitate to contribute if you want.

akondas commented 4 years ago

In my opinion, pixelToleranceLevel param can handle this problem pretty good. For example: 0.1

romankh3 commented 4 years ago

I thinks so, too. Nevertheless it must be double checked

Hexronimo commented 4 years ago

It really depends on the algorithm used to search for difference, it's quite possible that it will handle compression without any additional code. I can't run it (from.sh) to make test because it seems something wrong with my gradle, it says "Could not determine java version from '11.0.2'", I usually use maven and not particularly familiar with using gradlew.

romankh3 commented 4 years ago

@Hexronimo, @akondas, at the first look I want to say, that pixeltoleranceLevel helped with it. next tests

ImageComparisonResult imageComparisonResult = new ImageComparison(
                "images_for_test/test1_no_difference/test1_midi-size_0-compression.jpg",
                "images_for_test/test1_no_difference/test1_original_midi-size_no-compression.jpg")
                .compareImages();

pairs: | pixelOfToleranceLevel | ComparsionState | | 0.1 | MISMATCH | | 0.2 | MISMATCH | | 0.3 | MISMATCH | | 0.32 | MATCH |

Hexronimo commented 4 years ago

test jpeg with compression.pdf Here I tested it for you. Result: for big images 0.3 tolerance + 100-60%quality -> stable result

romankh3 commented 4 years ago

That's really great research. Thanks, @Hexronimo!

romankh3 commented 4 years ago

@Hexronimo, thanks for your research. I have added Wiki-page with it. My article(https://habr.com/ru/post/475482/) can be updated! I think, that this a great example of an open-source community and contribution.

Best regards, Roman.