You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

jpegtran wipe功能在彩色与灰度图中处理区域差异的技术问询

关于jpegtran处理灰度图与彩色转灰度图后wipe区域差异的疑问

在Debian/stable系统中运行实验脚本后,输出如下:

% ./demo.sh
26b955f9e6987c2617c97a653f1fe3dd  mask_white_gray.jpg
4fe7eb3d04c54887c1b0c9c33f8526bf  mask_gray.jpg

观察生成的中间图像可发现二者存在差异,执行以下命令生成对比图:

$ compare mask_white_gray.jpg  mask_gray.jpg -compose src diff.png

对比结果显示,mask_white_gray.jpg(彩色图先执行wipe操作再转灰度)的wipe区域比mask_gray.jpg(直接对灰度图执行wipe操作)更大。

根据jpegtran文档描述:

If the wipe region and the region outside the wipe region, when
adjusted to the nearest iMCU boundary [...]

按文档逻辑,两者的iMCU边界应该一致,无法理解为何会出现上述差异,恳请解释原因。

实验脚本

% cat demo.sh
#!/bin/sh
#set -x

convert -size 100x100 xc:white orig.ppm
cjpeg -outfile orig.jpg orig.ppm

jpegtran -copy none -outfile white.jpg orig.jpg
jpegtran -copy none -grayscale -outfile gray.jpg orig.jpg

jpegtran -wipe 50x50+0+0 -outfile mask_white.jpg white.jpg
jpegtran -wipe 50x50+0+0 -outfile mask_gray.jpg gray.jpg

jpegtran -grayscale -outfile mask_white_gray.jpg mask_white.jpg

md5sum mask_white_gray.jpg
md5sum mask_gray.jpg

使用的jpegtran版本

% jpegtran -version
libjpeg-turbo version 2.1.5 (build 20230203)

内容的提问来源于stack exchange,提问作者malat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 07:33:19