Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Add Support for Images not Div by 16 (Diff. JPEG) #2865

Merged
merged 5 commits into from Apr 3, 2024

Conversation

ChristophReich1996
Copy link
Contributor

@ChristophReich1996 ChristophReich1996 commented Apr 2, 2024

This pull request adds support for images not divisible by 16 to differentiable JPEG coding. As discussed in #2845 the current differentiable JPEG implementation just supports images that are divisible by 16. This is due to the fact that JPEG performs a (8 x 8) patch-wise DCT on downsampled (by 2) images. Thus the image must be divisible by 16. This pull request adds support for arbitrarily shaped images by performing padding and cropping. This implementation follows the common padding approach used before coding. In particular, the bottom and right sides of the image are padded by replication (see slide 442 of this reference). To go back to the original shape the JPEG-coded image is simply cropped again.

Type of change

  • 馃摎 Documentation Update
  • 馃И Tests Cases
  • 馃悶 Bug fix (non-breaking change which fixes an issue)
  • 馃敩 New feature (non-breaking change which adds functionality)
  • 馃毃 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 馃摑 This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Did you update CHANGELOG in case of a major change?

kornia/enhance/jpeg.py Outdated Show resolved Hide resolved
kornia/enhance/jpeg.py Outdated Show resolved Hide resolved
@edgarriba edgarriba merged commit 8f0f0c4 into kornia:main Apr 3, 2024
26 of 27 checks passed
cjpurackal pushed a commit to cjpurackal/kornia that referenced this pull request May 18, 2024
* Add support for images not div by 16 (diff JPEG)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update kornia/enhance/jpeg.py

Co-authored-by: Jian Shi <sj8716643@126.com>

* Remove if statements (both in pad and crop)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jian Shi <sj8716643@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants