标题提到。我试图绘制伽马色调曲线,但我不知道该怎么做。我可以很好地做线性色调曲线,但是当谈到绘制伽马色调曲线时,我完全失去了它。参考http://www.mediachance.com/pseam/help/curves.html(第1或第2图)
代码如下
#include <math.h>
static COLORREF red=RGB(255,0,0);
static COLORREF blue=RGB(0,0,255);
static COLORREF green=RGB(0,255,0);
我应该加入的部分来绘制伽马色调曲线
for(int y=0; y<bih.biHeight; y++)
{
for(int x=0; x<bih.biWidth; x++)
{
SetPixel(hdc, x, bih.biHeight-x, red);
}
// The X axis of the graph
HPEN hLinePen1;
COLORREF qLineColor1;
qLineColor1 = RGB(255, 0, 0);
hLinePen1 = CreatePen(PS_SOLID, 2, qLineColor1);
hPenOld1 = (HPEN)SelectObject(hdc, hLinePen1);
line(hdc,0, bih.biHeight, bih.biWidth, bih.biHeight);
SelectObject(hdc, hPenOld1);
DeleteObject(hLinePen1);
// The Y axis of the graph
HPEN hLinePen2;
COLORREF qLineColor2;
qLineColor2 = RGB(255, 0, 0);
hLinePen2 = CreatePen(PS_SOLID, 2, qLineColor2);
hPenOld2 = (HPEN)SelectObject(hdc, hLinePen2);
line(hdc,0, bih.biHeight, 0, bih.biWidth-bih.biHeight);
SelectObject(hdc, hPenOld2);
DeleteObject(hLinePen2);
答案 0 :(得分:1)
绘制图表应该很简单。对于你拥有的每个X点,计算相应的Y值 - 在Gamma的情况下,在0-255的范围内将是y = round(pow(x/255., gamma)*255)
。然后只需从上一个点到当前点绘制一条线。