如何以编程方式检测亮度
我正在为 iPad 创建一个应用程序,它可以通过检测房间的亮度来改变图像。所以我想知道有没有办法检测房间的亮度?
I am creating an application for iPad which can change the images by detecting the brightness of the room. So I want to know is there a way to detect the brightness of the room ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是获取图像中某些像素集的平均亮度。如果您有包含 RGB 像素的图像,则可以通过添加加权分量来获得亮度。常见的权重是 30% 红色、59% 绿色、11% 蓝色:
根据图像的变化、所需测量的准确度、图像的分辨率等。您可以对图像周围的像素样本进行平均,或者只是对它们进行平均。
One approach is to take the average brightness of some set of pixels in your image. If you have an image with RGB pixels, you can get the brightness by adding the weighted components. A common weighting is 30% red, 59% green, 11% blue:
Depending on the variations in your image, how accurate a measure you need, the resolution of your image, etc. you can average a sample of pixels from around the image, or just average all of them.