Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Finding Incompatible JPEG Blocks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Levecque Etienne
Finding Incompatible JPEG Blocks
Commits
5108a0b2
Commit
5108a0b2
authored
1 year ago
by
Levecque Etienne
Browse files
Options
Downloads
Patches
Plain Diff
test: fix a bug with naive offset
parent
876a9efe
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
antecedent/jpeg_toolbox.py
+2
-2
2 additions, 2 deletions
antecedent/jpeg_toolbox.py
test/test_jpeg_toolbox.py
+8
-1
8 additions, 1 deletion
test/test_jpeg_toolbox.py
with
10 additions
and
3 deletions
antecedent/jpeg_toolbox.py
+
2
−
2
View file @
5108a0b2
...
...
@@ -218,8 +218,8 @@ def jpeg_idct_naive(blocks: np.ndarray, quant_tbl: np.ndarray) -> np.ndarray:
Returns: an array with the same shape as blocks with DCT values.
"""
blocks
=
blocks
.
astype
(
float
)
+
128
return
idctn
(
blocks
*
quant_tbl
.
astype
(
np
.
uint16
),
axes
=
(
-
2
,
-
1
),
norm
=
'
ortho
'
)
blocks
=
blocks
.
astype
(
float
)
return
idctn
(
blocks
*
quant_tbl
.
astype
(
np
.
uint16
),
axes
=
(
-
2
,
-
1
),
norm
=
'
ortho
'
)
+
128
def
jpeg_idct_islow
(
blocks
:
np
.
ndarray
,
quant_tbl
:
np
.
ndarray
)
->
np
.
ndarray
:
...
...
This diff is collapsed.
Click to expand it.
test/test_jpeg_toolbox.py
+
8
−
1
View file @
5108a0b2
import
numpy
as
np
import
unittest
from
antecedent.jpeg_toolbox
import
llm_dct_islow
,
jpeg_fdct_islow
,
define_quant_table
,
quality_scaling_law
,
\
quantize_islow_fdct
quantize_islow_fdct
,
jpeg_fdct_naive
,
jpeg_idct_naive
,
jpeg_idct_islow
class
TestJPEGToolbox
(
unittest
.
TestCase
):
...
...
@@ -67,3 +67,10 @@ class TestJPEGToolbox(unittest.TestCase):
quantize_islow_fdct
(
split_blocks
[
2
],
chrominance
)],
axis
=
1
)
self
.
assertTrue
(
np
.
allclose
(
quantized_blocks
,
split_quantized_blocks
))
def
test_naive_dct_inversion
(
self
):
quant_tbl
=
np
.
ones
((
8
,
8
),
dtype
=
np
.
uint16
)
blocks
=
np
.
random
.
randint
(
0
,
256
,
size
=
(
1
,
1
,
8
,
8
),
dtype
=
np
.
int32
)
dct
=
jpeg_fdct_naive
(
blocks
)
spatial
=
jpeg_idct_naive
(
dct
,
quant_tbl
=
quant_tbl
)
self
.
assertTrue
(
np
.
allclose
(
spatial
,
blocks
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment