我正在尝试绘制在下面的纸质链接中流动的指数函数的值,但是,它们始终为零。我正在尝试绘制纸张中显示的灰色图像。你对此有何建议?谢谢
http://i.stack.imgur.com/2KyvO.png http://i.stack.imgur.com/pPend.png
Bitmap bm = (Bitmap)pictureBox1.Image;
Bitmap bmp = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
Color color = new Color();
double Cb,Cr,r,g,b,R,G,B;
double CbMean = 156.56;//150.3179;
double CrMean = 117.43;//117.1057;
double K1 = 160.13;
double K2 = 12.143;
double K3 = 12.143;
double K4 = 299.46;
for (int i = 0; i < pictureBox1.Width; i++)
{
for (int j = 0; j < pictureBox1.Height; j++)
{
color = bm.GetPixel(i, j);
R = Convert.ToDouble(color.R);
G = Convert.ToDouble(color.G);
B = Convert.ToDouble(color.B);
if (R != 0 && G != 0 && B != 0)
{
r = R / (R + G + B);
g = G / (R + G + B);
b = B / (R + G + B);
Cb = (-0.169 * r - 0.331 * g + 0.500 * b);
Cr = (0.500 * r - 0.418 * g - 0.082 * b);
Cb -= CbMean;
Cr -= CrMean;
double CbDist = (K1 * Cb) + (K3 * Cr);
double CrDist = (K2 * Cb) + (K4 * Cr);
double CbDist1 = (-0.5 * Cb) + (-0.5 * Cr);
double dist = CbDist + CrDist;
double dist1 = CrDist1;
double gmm = Math.Exp(dist * dist1); //<-------zero
int luma = (int)((gmm * 0.3) + (gmm * 0.59) + (gmm * 0.11));
bmp.SetPixel(i, j, Color.FromArgb(luma, luma, luma));
}
}
}