start01
start01

Reputation: 141

What equation used to implement the input level function of gimp in c?

I'd like to implement such as the level function of gimp by using c language. What equation used to implement the input level function of gimp?

I just thought that the original image's value range is between 0~255. but If I do adjust input level 0~206 from 0~255. then can I just do this?

adjusted pixel = Input pixel /255 * 206 ?

but I think this is not make sense, because the output range is more darker then before. how does the output image getting more brighter then before when I adjust input level?

enter image description here

Upvotes: 0

Views: 142

Answers (1)

xenoid
xenoid

Reputation: 8869

Easy to experiment. Create an image with a 256px-wide canvas. Create a Black-to-white RGB gradient across it. WIth the Pointer dialog (Windows>Dockable dialog>Pointer), it is easy to check that the pixels with horizontal coordinate x also have R=G=B=x (with minor variations).

Now apply the Levels tool. If you set the white point at 192 (255*3/4) then you can check that the pixels at x now have R=G=B=(x*4)/3 (this shows that the function is linear). In the Levels tool you can also hit Edit these settings at Curves to enter the Curves tool. And you will see that the corresponding curve is actually a straight line.

PS: The middle handle is the "gamma". Experimentally, you put it where that input value will be the average of the black and white points.

Upvotes: 1

Related Questions