Skip to content
Snippets Groups Projects
Commit e6512f85 authored by Levecque Etienne's avatar Levecque Etienne
Browse files

feat: change offset in naive DCT

parent aaeff027
No related branches found
No related tags found
No related merge requests found
...@@ -206,7 +206,7 @@ def jpeg_fdct_naive(blocks: np.ndarray) -> np.ndarray: ...@@ -206,7 +206,7 @@ def jpeg_fdct_naive(blocks: np.ndarray) -> np.ndarray:
Returns: an array with the same shape as blocks with DCT values. Returns: an array with the same shape as blocks with DCT values.
""" """
blocks = blocks.astype(float) blocks = blocks.astype(float)
return dctn(blocks, axes=(-2, -1), norm='ortho') return dctn(blocks - 128, axes=(-2, -1), norm='ortho')
def jpeg_idct_naive(blocks: np.ndarray, quant_tbl: np.ndarray) -> np.ndarray: def jpeg_idct_naive(blocks: np.ndarray, quant_tbl: np.ndarray) -> np.ndarray:
...@@ -218,7 +218,7 @@ def jpeg_idct_naive(blocks: np.ndarray, quant_tbl: np.ndarray) -> np.ndarray: ...@@ -218,7 +218,7 @@ 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. Returns: an array with the same shape as blocks with DCT values.
""" """
blocks = blocks.astype(float) blocks = blocks.astype(float) + 128
return idctn(blocks * quant_tbl.astype(np.uint16), axes=(-2, -1), norm='ortho') return idctn(blocks * quant_tbl.astype(np.uint16), axes=(-2, -1), norm='ortho')
......
...@@ -131,11 +131,11 @@ class NaivePipeline(JPEGPipeline): ...@@ -131,11 +131,11 @@ class NaivePipeline(JPEGPipeline):
return name == 'naive' return name == 'naive'
def dct(self, blocks): def dct(self, blocks):
return quantize_naive_fdct(jpeg_fdct_naive(blocks - 128), quant_tbl=self.quant_tbl[:blocks.shape[1]], return quantize_naive_fdct(jpeg_fdct_naive(blocks), quant_tbl=self.quant_tbl[:blocks.shape[1]],
return_int=self.return_rounded) return_int=self.return_rounded)
def idct(self, blocks): def idct(self, blocks):
return jpeg_idct_naive(blocks, self.quant_tbl[:blocks.shape[1]]) + 128 return jpeg_idct_naive(blocks, self.quant_tbl[:blocks.shape[1]])
class IslowPipeline(JPEGPipeline): class IslowPipeline(JPEGPipeline):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment