I have an image in a pictureBox.
How can I "get" the R, G, and B values of EACH PIXEL
(I know about looping..I need the instruction to actually "get" the values).
thanks,
xlthim
I have an image in a pictureBox.
How can I "get" the R, G, and B values of EACH PIXEL
(I know about looping..I need the instruction to actually "get" the values).
thanks,
xlthim
capturing pixel color
Moim Hossain
1. I need to cycle through EVERY pixel in the image, not move the mouse over the image.
For now, I'll just run a for loop and store them in an array.
What I'm trying to do is manipulate the R, G, and B of each pixel, then redraw after my corrections.
2. I tried to run your exe, and I need an SDK for IC Imaging Control.
If I can get past this part, I figure I could run the for loop and call your function.
tks
Found the IC Imaging stuff.
I'm not working with video - just static images....jpg/gif/tif....
GeorgeOu
private void button1_Click(object sender, EventArgs e) {
Bitmap bmp = new Bitmap(pictureBox1.Image);
ConvertToGray(bmp);
pictureBox1.Image = bmp;
}
Squirrelz
I put this code in a called function and it gathered the values fine. Why can I not see my form controls (pictureBox1) from inside the function What I'm wanting to do is redraw the edited pixel values back on top of the pictureBox using the bmp.SetPixel.
Right now, I'm writing the values out to a file and using another button to pull them back in and draw on the pictureBox (talk about SLOW!!!)
tks
dhall241
It may help you: http://www.imagingcontrol.com/library/dotnet/section/image-processing/example/accessing-image-data/
DaveRogers
public static void ConvertToGray(Bitmap bmp) {
for (int x = 0; x < bmp.Width; ++x) {
for (int y = 0; y < bmp.Height; ++y) {
Color c = bmp.GetPixel(x, y);
int gray = (299 * c.R + 587 * c.G + 114 * c.B) / 1000;
bmp.SetPixel(x, y, Color.FromArgb(gray, gray, gray));
}
}
}
This is not going to be fast. Search the forums or Google for ColorMatrix to quickly modify colors or LockBits to directly access pixel values using unsafe code. It all rather depends on what kind of operations you want to perform on what kind of bitmaps.