First time here? Check out the FAQ!

Ask Your Question
0

Color curve operation with OpenCV: Increase contrast

asked Dec 16 '13

Linke Seitentasche gravatar image

updated Dec 16 '13

Hi

With the Gimp image manipulation program, I frequently increase contrast by using the color curve tool. From this:

image description

to this:

image description

There is a small tutorial that talks about increasing contrast here: http://docs.opencv.org/doc/tutorials/core/basic_linear_transform/basic_linear_transform.html

Therefore, I assume this operation would give the desired effect:

image.convertTo(alpha: 1.3, beta: -20)

I would have to calculate the exact alpha and beta values in order to exactly represent the above color curve. Maybe anybody can comment on these assumptions or has suggestions?

Thank you very much.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Dec 22 '13

Linke Seitentasche gravatar image

updated Dec 24 '13

The following code calculates the appropriate measures:

    int xdist = indentRight - indentLeft; // indent as index from 0 to 256, for the above picture: indentRight: 235, indentLeft: 15
    double alpha = 256.0 / xdist;
    int beta = (int) -(indentLeft* alpha);
Preview: (hide)

Question Tools

Stats

Asked: Dec 16 '13

Seen: 3,173 times

Last updated: Dec 24 '13