【发布时间】:2021-09-15 14:18:25
【问题描述】:
目标
我这里有数百张看起来都与这张相似的图片:
我只是想使用绿屏为每个看起来像这里的图像创建一个蒙版(最好将边框平滑一点):
如果你想做测试,这里是原图:https://mega.nz/#!0YJnzAJR!GRYI4oNWcsKztHGoK7e4uIv_GvXBjMvyry7cPmyRpRA
我尝试过的
我发现this 帖子中用户使用 Imagemagick 实现色度键控。
for i in *; do convert $i -colorspace HSV -separate +channel \
\( -clone 0 -background none -fuzz 3% +transparent grey43 \) \
\( -clone 1 -background none -fuzz 10% -transparent grey100 \) \
-delete 0,1 -alpha extract -compose Multiply -composite \
-negate mask_$i; done;
我觉得自己真的很愚蠢,我自己找不到解决如此简单问题的方法。另请注意,我使用的是 Linux。所以没有 Photoshop 或 After Effects! :)
但我确信必须有解决这个问题的办法。
更新 1
我刚刚通过运行./greenscreen infile.jpg outfile.png 尝试使用this greenscreen script by fmw42,我对结果相当满意。
但是处理一张图像大约需要 40 秒,因此我的所有图像总共需要 8 小时(虽然我有一个相当强大的工作站,请参阅下面的规格)
也许这与处理时发生的错误有关?:
convert-im6.q16: width or height exceeds limit `black' @ error/cache.c/OpenPixelCache/3911.
convert-im6.q16: ImageSequenceRequired `-composite' @ error/mogrify.c/MogrifyImageList/7995.
convert-im6.q16: no images defined `./GREENSCREEN.6799/lut.png' @ error/convert.c/ConvertImageCommand/3258.
convert-im6.q16: unable to open image `./GREENSCREEN.6799/lut.png': No such file or directory @ error/blob.c/OpenBlob/2874.
convert-im6.q16: ImageSequenceRequired `-clut' @ error/mogrify.c/MogrifyImageList/7870.
convert-im6.q16: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `mask.png' @ warning/png.c/MagickPNGWarningHandler/1667.
工作站规格
- 内存:125,8 GiB
- 处理器:AMD® Ryzen 9 3900x 12 核处理器 × 24
- 显卡:GeForce GTX 970/PCIe/SSE2 (其中两个)
【问题讨论】:
-
你试过这个:fmwconcepts.com/imagemagick/greenscreen/index.php?如果这是用于商业项目,您需要付费才能使用它。
-
是的,它工作得很好,但是处理图像需要很长时间(请参阅我更新的问题)
-
关于我脚本中的错误消息,您的 ImageMagick 版本是多少?
标签: image image-processing imagemagick batch-processing chromakey