【解決方法】画像全体の RGB コードを取得するには?

プログラミングQA


How to get the RGB code of an entire image? The RGB code is to be displayed inside a textBox.in this form: RGB(148,149,155). If I change the brightness inside the image, the RGB code should also change inside. i cannot find RGB value of image and cannot see it  in textbox

私が試したこと:

C#
private void textBox3_TextChanged(object sender, EventArgs e)
		{
			GetPixels();
		}

private Color[,] GetPixels()
		{
			Bitmap bmp = varas.ptvalrgb;
			Color[,] results = new Color[bmp.Width, bmp.Height];

			for (int y = 0; y < bmp.Height; y++)
			{
				for (int x = 0; x < bmp.Width; x++)
				{
					results[x, y] = bmp.GetPixel(x, y);
				}
			}
			return results;
		}

//brightness code
private void trackBar1_Scroll(object sender, EventArgs e)
		{
			trackBar1.Value.ToString();
			float value = trackBar1.Value * 0.01f;
			float[][] colorMatrixElements = {
				new float[]
				{
					1,
					0,
					0,
					0,
					0
				},
				new float[]
				{
					0,
					1,
					0,
					0,
					0
				},
				new float[]
				{
					0,
					0,
					1,
					0,
					0
				},
				new float[]
				{
					0,
					0,
					0,
					1,
					0
				},
				new float[]
				{
					value,
					value,
					value,
					0,
					1
				}
			};
			ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
			ImageAttributes imageAttributes = new ImageAttributes();
			imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
			Image _img = varas.ptval;//varas.ptval is a bitmap image 
			//PictureBox1.Image
			Graphics _g = default(Graphics);
			Bitmap bm_dest = new Bitmap(Convert.ToInt32(_img.Width), Convert.ToInt32(_img.Height));
			_g = Graphics.FromImage(bm_dest);
			_g.DrawImage(_img, new Rectangle(0, 0, bm_dest.Width + 1, bm_dest.Height + 1), 0, 0, bm_dest.Width + 1, bm_dest.Height + 1, GraphicsUnit.Pixel, imageAttributes);
			LevelPicBox.Image = bm_dest;
			textBox1.Text = trackBar1.Value.ToString();
		}

解決策 1

解決策 2

これはとても混乱していて、答えがありません。 画像の明るさが変化したときにRGB値を表示したいと言っていますが、明るさの変化を検出するために何もしません。

表示中 全て テキストボックス内のピクセル RGB 値は意味がありません。

画像の明るさを見つけるためのテクニック: [^].

全体的な明るさの変化を検出するには、ループして以前と現在の明るさを比較する必要があります。

先生と話して、課題が実際に何であるかを明確にする必要があります。

テキスト ボックスに平均の明るさがあり、それが別の有効な RGB 値に変更された場合、画像の明るさを変更するために必要なことは複雑です。 [^]

コメント

タイトルとURLをコピーしました