开发者

Generic algorithm to get and set the brightness of a pixel?

开发者 https://www.devze.com 2023-03-27 00:23 出处:网络
I\'ve been looking around for a simple algorithm to get and set the brightness of a pixel, but can\'t find anything - only research papers and complex libraries.

I've been looking around for a simple algorithm to get and set the brightness of a pixel, but can't find anything - only research papers and complex libraries.

开发者_如何学Python

So does anyone know what is the formula to calculate the brightness of a pixel? And which formula should I use to change the brightness?

Edit: to clarify the question. I'm using Qt with C++ but I'm mainly looking for a generic math formula - I will adapt it to the language. I'm talking about RGB pixels of an image in memory. By "brightness", I mean the same as in Photoshop - changing the brightness makes the image more "white" (a brightness value of 1.0 is completely white), decreasing it makes it more "black" (value of 0.0).


Change the color representation to HSV. The V component stands for value and represents the brightness!

  • Here the algorithm implemented in PHP.
  • Here is a description of how to do it in C.


What do you mean by a pixel?

You can set the brightness of a pixel in an image with '=' you just need to know the memory layout of the image

To set a pixel on the screen is a little more complicated

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号