【问题标题】:A code for step by step JPEG compression逐步 JPEG 压缩的代码
【发布时间】:2013-08-12 12:55:04
【问题描述】:

JPEG压缩步骤如下:

原始图像数据 -> 正向 DCT -> 量化 -> 熵编码 -> JPEG 图像

那里有许多转换器和 API,转换过程是单个 API 调用。我无法找到一步一步的代码。我的问题是在哪里可以找到每个单独步骤的代码,或者我可以一个一个地执行这些单独的步骤并生成标准的 JPEG 图像?我正在为我的图像隐写项目使用 EmguCV。

【问题讨论】:

    标签: image jpeg emgucv steganography image-conversion


    【解决方案1】:

    在哪里可以找到每个步骤的代码

    如果 C 库可能适合您,您应该看看 jpec 一个用 C 编写的轻量级 JPEG 编码器 - 请注意,它只支持灰度图像。

    主编码函数(jpec_enc_run)易于阅读,并通过内部函数提供上述每个步骤:

    /* open = write JPEG headers */
    jpec_enc_open(e);
    
    while (jpec_enc_next_block(e)) {
      /* compute the DCT for the current 8x8 block */
      jpec_enc_block_dct(e);
    
      /* quantize the DCT coefficients for the current block */
      jpec_enc_block_quant(e);
    
      /* re-order the quantized coefficients with the zig-zag pattern */
      jpec_enc_block_zz(e);
    
      /* perform entropy coding of the current block and write to the global buffer*/
      e->hskel->encode_block(e->hskel->opq, &e->block, e->buf);
    }
    
    /* close = write JPEG end of image marker */
    jpec_enc_close(e);
    

    我可以逐个执行这些单独的步骤并生成标准的 JPEG 图像

    这不是 jpec 开箱即用的,但您应该能够很容易地为此目的对其进行修改(通过公开和/或调整低级内部函数)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-02
      • 2011-03-29
      • 2011-08-09
      • 1970-01-01
      • 2011-12-15
      • 1970-01-01
      • 2013-02-22
      相关资源
      最近更新 更多