去除JPG图像中的高频系数

发布于 2024-12-23 07:37:38 字数 631 浏览 1 评论 0原文

根据这个问题的答案,我需要从我的解压时对图像进行压缩以获得较小的图像。

我一直在寻找一种方法来做到这一点,但似乎并不那么简单。我有以下两个循环在我的代码中执行 IDCT,并且在 8 x 8 块的子集上执行循环,仅给出非常扭曲的图像。

 for (coef = 0;  coef < 64;  coef +=8)
        njRowIDCT(&nj.block[coef]); //Inverse Discrete Cosine Transform
    for (coef = 0;  coef < 8;  ++coef)
        njColIDCT(&nj.block[coef], &out[coef], c->stride);  // Inverse Discrete Cosine Transform

block 是一个 64 int 的数组,

我知道我需要删除的系数位于每个块的右下角,但是最好的方法是什么正确移除或丢弃它们?

Based on this question's answer, I need to remove the high-frequency DCT coefficients from my image during decompression to get a smaller image.

I've been searching for a way to do this, and it seems it's not that simple. I have the following two loops that do the IDCT in my code, and doing the loops over a subset of the 8 x 8 blocks, only gives very distorted images.

 for (coef = 0;  coef < 64;  coef +=8)
        njRowIDCT(&nj.block[coef]); //Inverse Discrete Cosine Transform
    for (coef = 0;  coef < 8;  ++coef)
        njColIDCT(&nj.block[coef], &out[coef], c->stride);  // Inverse Discrete Cosine Transform

block is an array of 64 int's

I know that the coefficients I need to remove are in the lower right corner of each block, however what would be the best method of removing or discarding them properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屋顶上的小猫咪 2024-12-30 07:37:38

我认为,简单地丢弃高频成分是行不通的。你的观察也证明了这一点。因为,当您对 2x2 或 4x4 块进行平均时,您不会完全丢弃某个高频分量。相反,你会降低它们相对于低频的能量水平。因此,完全减少到零并不是一个好主意。

我认为,您没有足够重视高频的真正含义。请对您的图像应用 Sobel 或 Prewitt 边缘检测并将其二值化。然后查询该二值图像上的每个像素是否是边缘的一部分或被丢弃。如果它是边缘的一部分,则通过“排除”当前像素在原始图像上应用平均过滤器。现在,猜猜它是什么样子?

I think, simply discarding high frequency components won't work. Your observation also proves that. Because, when you average 2x2 or 4x4 block, you won't completely discard a certain high frequency component. Instead, you decrease their energy level respect to low frequencies. So, decreasing completely to zero is not good idea.

I think, you didn't pay attention enough what high frequency really means. Please apply a Sobel or Prewitt edge detection to your image and binarize it. Then query each pixel on that binary image that whether it's a part of edge or discarded. If it's a part of edge, then apply an average filter on your original image by "excluding" current pixel. Now, guess what it looks like?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文