PHP - 替换图像中的颜色
我希望有人可以提供帮助,
我制作了一个掩盖图像的脚本......但是它依赖于掩盖的颜色(“绿屏”样式)。问题是,如果我要遮盖的图像包含该颜色,它就会被破坏。
我想做的是在遮盖图像之前将出现的任何键控颜色 (0,0,255) 替换为类似的颜色,例如 0,0,254。
我找到了一些基于 gif 或 256 色 PNG 的解决方案,因为它们被索引了。
所以我的问题是将其转换为 gif 或 256 png 然后查看索引并替换颜色或搜索是否会更有效每个像素并替换颜色。
谢谢,
I hope someone can help,
I have made a script that masks images... however it is reliant on a colour to mask with ( 'green screen' style). The trouble is if the image that I am masking contains that colour it is ruined.
What I am looking to do is prior to masking the image replace any occurance of my keying colour (0,0,255) with a similar colour such as 0,0,254.
I have found a few solutions based around gif's or 256 colour PNG as they are indexed..
So my question is also will it be more efficient to convert it to a gif or 256 png then look through the index and replace the colour or search through every pixel and replace the colours.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要打开输入文件并扫描每个像素以检查色键值。
像这样的东西:
You need to open the input file and scan each pixel to check for your chromokey value.
Something like this:
这是首先转换为 256 调色板的替换颜色解决方案:
我个人更喜欢 radio4fans 解决方案,因为它是无损的,但如果速度是您的目标,那么这是优越的。
Here is the replace colour solution that first converts to 256 pallet:
I personally prefer radio4fans solution as it is lossless, but if speed is your goal this is superior.