色键 Chroma Key
来源:互联网 发布:浙江慧达网络驿站招聘 编辑:程序博客网 时间:2024/05/06 09:28
整理下色键代码
ffmpeg
typedef struct ColorkeyContext { const AVClass *class; /* color offsets rgba */ int co[4]; uint8_t colorkey_rgba[4]; float similarity; float blend;} ColorkeyContext;static uint8_t do_colorkey_pixel(ColorkeyContext *ctx, uint8_t r, uint8_t g, uint8_t b){ int dr = (int)r - ctx->colorkey_rgba[0]; int dg = (int)g - ctx->colorkey_rgba[1]; int db = (int)b - ctx->colorkey_rgba[2]; double diff = sqrt((dr * dr + dg * dg + db * db) / (255.0 * 255.0)); if (ctx->blend > 0.0001) { return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * 255.0; } else { return (diff > ctx->similarity) ? 255 : 0; }}gpuimage
// from: https://github.com/BradLarson/GPUImage/blob/master/framework/Source/GPUImageChromaKeyFilter.m#ifdef GL_ESprecision mediump float;precision mediump int;#endif#define PROCESSING_TEXTURE_SHADERuniform sampler2D texture;varying vec4 vertColor;varying vec4 vertTexCoord;uniform float thresholdSensitivity;uniform float smoothing;uniform vec3 colorToReplace;void main(){ vec4 textureColor = texture2D(texture, vertTexCoord.xy); float maskY = 0.2989 * colorToReplace.r + 0.5866 * colorToReplace.g + 0.1145 * colorToReplace.b; float maskCr = 0.7132 * (colorToReplace.r - maskY); float maskCb = 0.5647 * (colorToReplace.b - maskY); float Y = 0.2989 * textureColor.r + 0.5866 * textureColor.g + 0.1145 * textureColor.b; float Cr = 0.7132 * (textureColor.r - Y); float Cb = 0.5647 * (vertColor.b - Y); float blendValue = smoothstep(thresholdSensitivity, thresholdSensitivity + smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb))); gl_FragColor = vec4(textureColor.rgb, textureColor.a * blendValue);}
</pre><p></p><p>http://gc-films.com/chromakey.html </p><p></p><pre code_snippet_id="1562456" snippet_file_name="blog_20160125_4_8238969" name="code" class="cpp">double colorclose(int Cb_p,int Cr_p,int Cb_key,int Cr_key,int tola,int tolb) { /*decides if a color is close to the specified hue*/ double temp = sqrt((Cb_key-Cb_p)*(Cb_key-Cb_p)+(Cr_key-Cr_p)*(Cr_key-Cr_p)); if (temp < tola) {return (0.0);} if (temp < tolb) {return ((temp-tola)/(tolb-tola));} return (1.0); }
http://www.cs.utah.edu/~michael/chroma/
High Quality Chroma Key
这个代码我实现了一下 效果远远达不到要求 专业的摄像机效果好点
头发没法抠出来
0 0
- 色键 Chroma Key
- c# chroma key 绿被抠像
- 转载 High Quality Chroma Key
- chroma
- chroma key (绿背景抠图)
- 图像算法研究---Luma-Key,Chroma-Key抠图
- 几种抠象技术理论试验-1 (Luma-Key,Chroma-Key)
- 使用FFmpeg实现抠图合并功能(chroma key)
- 使用FFmpeg实现抠图合并功能(chroma key)
- 【转载】几种抠象技术理论试验-1 (Luma-Key,Chroma-Key)
- chroma subsampling
- H264 Chroma prediction modes
- Intra chroma prediction
- 实例详解CSS滤镜(4)Chroma属性
- Chroma属性实现CSS滤镜透明效果
- css3滤镜-色彩(Chroma)滤镜
- KEY
- Key
- ubuntu的virtualbox
- Android 优化布局:
- 关于自定义控件:
- Android 视图绘制流程:
- UNIX中域套接字的简单实例
- 色键 Chroma Key
- 浏览器要倒霉了!
- 使用git命令行上传代码到github中
- wyh2000 and a string problem(HDU5284)
- java gzip 内存压缩
- Android5.1--APK包的安装、卸载和优化(PackageManagerService)
- spring IoC
- 高通耳机检测分析
- iOS CUICatalog: Invalid asset name supplied: