Image processing problem...
-
how can i change the contrast of the image at the same time changing brightness. my brightness can change. its working fine i want to change the contrast at the same time....can i use this method too ???
Bitmap image = new Bitmap("d:\\\\14.jpg"); Bitmap bm = new Bitmap(image, 350, 300); System.Drawing.Bitmap TempBitmap = bm; float FinalValue = 0.5f; System.Drawing.Bitmap NewBitmap = new System.Drawing.Bitmap(TempBitmap.Width, TempBitmap.Height); System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap); float\[\]\[\] FloatColorMatrix ={ 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\[\] {FinalValue, FinalValue, FinalValue, 1, 1} }; System.Drawing.Imaging.ColorMatrix NewColorMatrix = new System.Drawing.Imaging.ColorMatrix(FloatColorMatrix); System.Drawing.Imaging.ImageAttributes Attributes = new System.Drawing.Imaging.ImageAttributes(); Attributes.SetColorMatrix(NewColorMatrix); NewGraphics.DrawImage(TempBitmap, new System.Drawing.Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, System.Drawing.GraphicsUnit.Pixel, Attributes); Attributes.Dispose(); NewGraphics.Dispose(); picDecode.Image = NewBitmap;
A S E L A
-
how can i change the contrast of the image at the same time changing brightness. my brightness can change. its working fine i want to change the contrast at the same time....can i use this method too ???
Bitmap image = new Bitmap("d:\\\\14.jpg"); Bitmap bm = new Bitmap(image, 350, 300); System.Drawing.Bitmap TempBitmap = bm; float FinalValue = 0.5f; System.Drawing.Bitmap NewBitmap = new System.Drawing.Bitmap(TempBitmap.Width, TempBitmap.Height); System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap); float\[\]\[\] FloatColorMatrix ={ 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\[\] {FinalValue, FinalValue, FinalValue, 1, 1} }; System.Drawing.Imaging.ColorMatrix NewColorMatrix = new System.Drawing.Imaging.ColorMatrix(FloatColorMatrix); System.Drawing.Imaging.ImageAttributes Attributes = new System.Drawing.Imaging.ImageAttributes(); Attributes.SetColorMatrix(NewColorMatrix); NewGraphics.DrawImage(TempBitmap, new System.Drawing.Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, System.Drawing.GraphicsUnit.Pixel, Attributes); Attributes.Dispose(); NewGraphics.Dispose(); picDecode.Image = NewBitmap;
A S E L A
You can add the contrast and brightness matrices, I guess, or you can apply one, then the other.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
You can add the contrast and brightness matrices, I guess, or you can apply one, then the other.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
i could do it....but i got a big problem. as i told im doing a QR barcode reader by using webcam. my web cam pictures are too dark so i have to process image before i send it to decode. some times after process i code decode.but when the envirentmant change it couldn't decode. that mean when change brightness and contrast in enviranmetn i couldn't decode. is there any solution....may be auto brightness and contrast detect or some thing else....???
A S E L A
-
i could do it....but i got a big problem. as i told im doing a QR barcode reader by using webcam. my web cam pictures are too dark so i have to process image before i send it to decode. some times after process i code decode.but when the envirentmant change it couldn't decode. that mean when change brightness and contrast in enviranmetn i couldn't decode. is there any solution....may be auto brightness and contrast detect or some thing else....???
A S E L A
Hi, I think you want a non-linear transformation, ideally something that maps all colors to either black or white. Maybe ImageAttributes.SetThreshold could help you out, provided you give it a good value, at best it would depend on the average brightness of your image, :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.