Adaptive Weighted Exposure Algorithm Based on Region Luminance Detection 一、背景 首先将整个成像视野划分为几个区域,然后通过独立判断识别目标在视野中的位置 个区域为0.025 四、算法效果 各种灯光分布在靶体的LED灯板上可以清晰可见 四、参考文献 《Adaptive Weighted Exposure Algorithm Based on Region Luminance
+1.0)) + (-0.76)*pow(luminance, 2.0/(shadows+1.0))) - luminance, 0.0, 1.0); mediump float highlight = clamp((1.0 - (pow(1.0-luminance, 1.0/(2.0-highlights)) + (-0.8)*pow(1.0-luminance, 2.0/(2.0-highlights )))) - luminance, -1.0, 0.0); lowp vec3 result = vec3(0.0, 0.0, 0.0) + ((luminance + shadow + highlight + (-0.76)*pow(luminance, 2.0/(shadows+1.0))) - luminance, 0.0, 1.0); float highlight = clamp((1.0 - (pow(1.0-luminance, 1.0/(2.0-highlights)) + (-0.8)*pow(1.0-luminance, 2.0/(2.0-highlights)))) - luminance
float lineWidth; const highp vec3 W = vec3(0.2125, 0.7154, 0.0721); void main() { highp float luminance lineWidth) { colorToDisplay = vec4(0.0, 0.0, 0.0, 1.0); } } if (luminance lineWidth) { colorToDisplay = vec4(0.0, 0.0, 0.0, 1.0); } } if (luminance lineWidth) { colorToDisplay = vec4(0.0, 0.0, 0.0, 1.0); } } if (luminance uniform float lineWidth; const vec3 W = vec3(0.2125, 0.7154, 0.0721); void main() { float luminance
和 GL_LUMINANCE_ALPHA 格式的纹理,其中 GL_LUMINANCE 纹理用来加载 NV21 Y Plane 的数据,GL_LUMINANCE_ALPHA 纹理用来加载 UV Plane OpenGLES 常用纹理的格式类型 GL_LUMINANCE 纹理在着色器中采样的纹理像素格式是(L,L,L,1),L 表示亮度。 GL_LUMINANCE 纹理在着色器中采样的纹理像素格式是(L,L,L,A),A 表示透明度。 , m_RenderImage.width, m_RenderImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_RenderImage.ppPlane , m_RenderImage.width, m_RenderImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_RenderImage.ppPlane
,GL_LUMINANCE_ALPHA 等 通常使用的GL_RGBA这种internalformat,它会单独保存R,G,B,A四个数据,而在渲染YUV数据的时候,我们使用GL_LUMINANCE和GL_LUMINANCE_ALPHA 使用GL_LUMINANCE的时候,可以将Y分量存储到像素的各个通道内,这样在着色器中,我们可以通过R,G,B任意一个分量来获取到Y值。 U,V分量同理 使用GL_LUMINANCE_ALPHA的时候,首先存储亮度,然后是alpha值,利用这一点可以将U值存储到像素的A通道,V值存储到R,G,B通道 渲染i420 在使用GL渲染i420格式的 YUV数据时,需要使用三个2D纹理,每个纹理的颜色组件采用GL_LUMINANCE private fun textureLuminance(imageData: ByteBuffer, width: 从纹理中提取Y,U,V分量 // We had put the Y values of each pixel to the R, G, B components by GL_LUMINANCE, //
inout SurfaceOutput o) { float4 c = tex2D(_MainTex,IN.uv_MainTex); c.rgb = lerp(c.rgb,Luminance (c.rgb),_DesatValue); o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG } } 参数详情 1.Luminance 简单的说Luminance就是实现灰阶公式的函数。 位于UnityCG.glslinc 具体实现如下 // Converts color to luminance (grayscale) float Luminance( vec3 c ) { return
y < height; y++) { row = getRow(y, row); for (int x = 0; x < width; x++) { int luminance = row[x] & 0xFF; char c; if (luminance < 0x40) { c = '#'; } else if (luminance < 0x80) { c = '+'; } else if (luminance < 0xC0) { c = ' c); } result.append('\n'); } return result.toString(); } ---- 阅读到上述源代码时,对于int luminance Java中unsigned byte 的转换 正如上述我们看到的代码所示: int luminance = row[x] & 0xFF; 首先widening类型。
main() { lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float luminance = dot(textureColor.rgb, W); gl_FragColor = vec4(vec3(luminance), textureColor.a); } ); #else void main() { vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float luminance = dot(textureColor.rgb, W); gl_FragColor = vec4(vec3(luminance), textureColor.a); } ); #endif
, yWidth, yHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL); if (! , uWidth, uHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL); if (! , vWidth, vHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL); if (! GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_YTextureId); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, m_UTextureId); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE
和 GL_LUMINANCE_ALPHA 格式的纹理,其中 GL_LUMINANCE 纹理用来加载 NV21 Y Plane 的数据,GL_LUMINANCE_ALPHA 纹理用来加载 UV Plane OpenGLES 常用纹理的格式类型 GL_LUMINANCE 纹理在着色器中采样的纹理像素格式是(L,L,L,1),L 表示亮度。 GL_LUMINANCE_ALPHA 纹理在着色器中采样的纹理像素格式是(L,L,L,A),A 表示透明度。 , m_RenderImage.width, m_RenderImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_RenderImage.ppPlane , m_RenderImage.width, m_RenderImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_RenderImage.ppPlane
Ryan Dahl - An interesting case with Deno 链接:https://dev.to/ajcwebdev/deno-internal-organization-10mj luminance -0.40 luminance 之前是包裝 OpenGL 3.3 的庫,作者一直希望將luminance更新的更好。 這次提供了 luminance-webgl 與 luminance-gl 支援 webgl 與舊機器 luminance-sdl2支援 sdl2 luminance-front方便跨平台 希望大家繼續關注我 链接:https://phaazon.net/blog/luminance-0.40 -- From 日报小组 北纬27度 社区学习交流平台订阅: Rustcc论坛: 支持rss 微信公众号:Rust
向上查找Luminance来源自HDRSceneColorSampler: ? 而HDRSceneColorTexture就是Toonmap前的SceneColor: ? 那么Luminance = max(SceneColorBeforeTonemap.r, max(SceneColorBeforeTonemap.g, SceneColorBeforeTonemap.b PS: UE4中的LinearColor To Luminance我找到了三种算法: EyeAdaption Shader里是dot(OutColor.xyz, float3(1.0f, 1.0f, PostProcessVisualizeHDR里是max(LuminanceAvg.r, max(LuminanceAvg.g, LuminanceAvg.b)), 即max(r, g, b) Bloom里Luminance
); glBindTexture(GL_TEXTURE_2D, m_TextureIds[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE , m_RenderImage.width, m_RenderImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, ); glBindTexture(GL_TEXTURE_2D, m_TextureIds[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE , m_RenderImage.width, m_RenderImage.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, ); glBindTexture(GL_TEXTURE_2D, m_TextureIds[1]); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE
HDR技术 优点 缺点 Dolby VisionTM - 12-bit colors- Luminance up to 10000 nits (4000 nits current target) - future Can be used for live and pre-recorded contents - Lack of Dynamic Metadata (per scene)- 10-bit colors- Luminance additional HDR10+ metadata creation (complicates existing workflow based on DV/HDR10)- 10-bit colors- Luminance
, GL_LUMINANCE_ALPHA 等几种 width:指定纹理图像的宽度,必须是2的n次方 height:指定纹理图像的高度,必须是2的n次方 border:指定边框的宽度,必须为0 format 它又给我们提供了GL_LUMINANCE这种格式,它表示只取一个颜色通道,假如传入的值为r,则在片段着色器中的纹理单元中读出的值为(r,r,r,1)。 glBindTexture(GL_TEXTURE_2D,textures[1]) glTexImage2D(GL_TEXTURE_2D,0, GL_LUMINANCE,W/2,H/2,0 , GL_LUMINANCE, GL_UNSIGNED_BYTE,bufferU) //v平面 glActiveTexture(GL_TEXTURE2) glBindTexture(GL_TEXTURE_2D,textures[2]) glTexImage2D(GL_TEXTURE_2D,0, GL_LUMINANCE,W/2,H/2,0
main() { lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); lowp float luminance = dot(textureColor.rgb, luminanceWeighting); lowp vec3 greyScaleColor = vec3(luminance); gl_FragColor void main() { vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float luminance = dot(textureColor.rgb, luminanceWeighting); vec3 greyScaleColor = vec3(luminance); gl_FragColor
main() { lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float luminance textureColor.rgb, luminanceWeighting); gl_FragColor = vec4( mix(firstColor.rgb, secondColor.rgb, luminance void main() { vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float luminance textureColor.rgb, luminanceWeighting); gl_FragColor = vec4( mix(firstColor.rgb, secondColor.rgb, luminance
displayPixelBuffer:pixelBuffer]; 2、图像纹理数据创建 这一部分的代码参考自GPUImage的GPUImageVideoCamera类,YUV视频帧分为亮度和色度两个纹理,分别用GL_LUMINANCE 格式和GL_LUMINANCE_ALPHA格式读取。 GL_TEXTURE_2D, GL_LUMINANCE frameHeight, GL_LUMINANCE GL_TEXTURE_2D, GL_LUMINANCE_ALPHA
overlay blend lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float luminance = dot(textureColor.rgb, luminanceWeighting); lowp vec4 desat = vec4(vec3(luminance), 1.0); overlay blend vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float luminance = dot(textureColor.rgb, luminanceWeighting); vec4 desat = vec4(vec3(luminance), 1.0); //
author, publisher, isbn, pub_date, desc, contributor); } Repo: https://github.com/wojciechkepka/mobi-rs luminance-rs - 类型安全/type-level和无状态的 Rust 图形框架 luminance 致力于让图形渲染变得简单优雅。 provides you with an experience focused on down-to-metal performance and an API very similar to Vulkan’s, luminance Repo: https://github.com/phaazon/luminance-rs icon-pie - 用命令行产生应用程序图标 用来将已有素材,转换,合成标准的 icon 规范的图标。