使用煤渣转换为灰度
convert to grayscale with cinder
我正在学习有关 Cinder 的教程,您可以在其中加载图像并将其显示为cinder::gl::Texture
对象。此类没有convert2Grayscale
方法,因此我自己可以实现这样的事情吗?我是否可以访问分离像素,在那里我可以应用简单的算法?(访问像素实际上更重要,因为我想将其用于另一个项目)
每个像素由一个 3D 矢量 [R,G,B] 表示其中 R 是红色通道 [0,1] 中的值,G 是绿色通道 [0,1] 中的值,B 是蓝色通道 [0,1] 中的值。将 3D RGB 像素转换为标量 Y 的最简单方法是使用以下公式:
Y = .2126 * R^gamma + .7152 * G^gamma + .0722 * B^gamma
其中大多数系统中的伽马等于 2.2
现在,就访问煤渣中图像的像素而言,您必须将图像加载到Surface对象上。煤渣中的表面对象具有用于访问单个像素的接口功能。请参阅这个关于如何做到这一点的惊人教程:http://www.creativeapplications.net/tutorials/images-in-cinder-tutorials-cinder/
更简单的方法,如Cinder网站上的"Hello, Cinder"教程所示:
- 将图像加载到 Channel 对象中,默认情况下,该对象会立即将其全部转换为灰度。
-
使用该通道对象初始化可在
draw()
方法中使用的 Surface 对象,如下所示:void MyApp::setup(){
Url url( "http://libcinder.org/media/tutorial/paris.jpg" ); mChannel = Channel32f( loadImage( loadUrl( url ) ) ); mTexture = mChannel; mDrawImage = true;
}
void TutorialApp::d raw()
{
gl::clear( Color( 0, 0, 0 ), true ); if( mDrawImage ) { mTexture.enableAndBind(); gl::draw( mTexture, getWindowBounds() ); }
}
相关文章:
- OpenCV - 如何将灰度转换为彩色(CV_8UC3)?
- C++ Gdi+将图像转换为灰度
- 将 BMP 图像转换为灰度
- 颜色到灰度转换
- 如何将图像转换为灰度 opengl c++
- 如何正确将位图转换为 OpenCV 灰度垫
- 将 YUV420p QVideoFrame 转换为灰度 OpenCV 垫
- Qmage:使用颜色表从灰度转换为RGB
- 在OpenCV中将灰度图像转换为单色
- Mat的convertTo函数在OpenCV中将灰度图像的类型转换为CV_32F时抱怨断言错误
- 使用某些系数将图像转换为灰度的最快方法
- OPENCV:从RGB转换为灰度只有蓝色
- 在C++中将彩色位图转换为灰度
- 如何将灰度/二进制垫子转换为qimage
- 使用libpng将转换设置为灰度
- 使用煤渣转换为灰度
- 将颜色图像转换为OpenCV中的灰度问题
- 在open cv中,我如何将灰度图像转换回RGB图像(颜色)
- 我正在尝试将灰度转换为更大的黑色图像.我得到这个错误OpenCV错误:断言失败
- 将图像颜色从灰度转换为RGB OpenCV C++