/// <summary> /// Convert this color to an hex string with format #AARRGGBB /// </summary> /// <returns>Hex string.</returns> public string ColorToHex() { return(String.Format("#{0}{1}{2}{3}" , Ab.ToString("X").Length == 1 ? String.Format("0{0}", Ab.ToString("X")) : Ab.ToString("X") , Rb.ToString("X").Length == 1 ? String.Format("0{0}", Rb.ToString("X")) : Rb.ToString("X") , Gb.ToString("X").Length == 1 ? String.Format("0{0}", Gb.ToString("X")) : Gb.ToString("X") , Bb.ToString("X").Length == 1 ? String.Format("0{0}", Bb.ToString("X")) : Bb.ToString("X"))); }
//偏差指数评价 private void button2_Click(object sender, EventArgs e) { double Br, Bg, Bb;//三通道偏差指数 double r, g, b; r = g = b = 0; Bitmap map2 = (Bitmap)img2; for (int i = 0; i < newBitmap.Width; i++) { for (int j = 0; j < newBitmap.Height; j++) { Color pixel1 = newBitmap.GetPixel(i, j); Color piexl2 = map2.GetPixel(i, j); r += Math.Abs(pixel1.R - piexl2.R) * 1.0 / piexl2.R; g += Math.Abs(pixel1.G - piexl2.G) * 1.0 / piexl2.G; b += Math.Abs(pixel1.B - piexl2.B) * 1.0 / piexl2.B; } } Br = r / (newBitmap.Width * newBitmap.Height); Bg = g / (newBitmap.Width * newBitmap.Height); Bb = b / (newBitmap.Width * newBitmap.Height); MessageBox.Show("融合图三通道偏差指数" + "\r\n" + "Br:" + Br.ToString() + " " + "Bg:" + Bg.ToString() + " " + "Bb:" + Bb.ToString()); }