Image Brightness and Contrast change together
-
Guys, I need help. Sorry for my English now,my brain just refused to work. I have an Image in PictureBox and have some filters to its process: contrast and brightness. Two trackbars controls filters changing values. When trackBar1_ValueChanged or trackBar2_ValueChanged events raises, function ApplyFilter() starts to work in different thread. When I using the brightness trackbar it changes the brightness of basic image. When I using the contrast trackbar it changes the contrast of image, But I don't know how to change the brightness and contrast together and show it in pictureBox component. For example I want to increase a brightness of an image. After that I want to increase a contrast but not of basic image, and what has turned out at brightness increase. After that I want to decrease a brightness to its basic level or lower. I don't know How to explain it clearly... If anybody have Vista you can see the same example in Vista PhotoGallery fix component. There are a lot of filters which you can apply to your image and change it back as you need. Here is a logic of my code...
Bitmap previewimage = null;
int brightness_value = 0;
int contrast_value = 0;public PicPreviewForm(string filename)
{
previewimage = new Bitmap(Image.FromFile(filename));
pictureBox1.Image = previewimage;
}
public void ApplyFilter()
{
Bitmap bit;
bit = new Bitmap(previewimage);if(brightness had been changed)
{
BrightnessFilter(bit, brightness_value);
}
If(contrast had been changed)
{
ContrastFilter(bit, contrast_value);
}
PictureBox.Image = bit;}
I could apply all filters every time when I changing some trackbar but it really decrease program performance..
-
Guys, I need help. Sorry for my English now,my brain just refused to work. I have an Image in PictureBox and have some filters to its process: contrast and brightness. Two trackbars controls filters changing values. When trackBar1_ValueChanged or trackBar2_ValueChanged events raises, function ApplyFilter() starts to work in different thread. When I using the brightness trackbar it changes the brightness of basic image. When I using the contrast trackbar it changes the contrast of image, But I don't know how to change the brightness and contrast together and show it in pictureBox component. For example I want to increase a brightness of an image. After that I want to increase a contrast but not of basic image, and what has turned out at brightness increase. After that I want to decrease a brightness to its basic level or lower. I don't know How to explain it clearly... If anybody have Vista you can see the same example in Vista PhotoGallery fix component. There are a lot of filters which you can apply to your image and change it back as you need. Here is a logic of my code...
Bitmap previewimage = null;
int brightness_value = 0;
int contrast_value = 0;public PicPreviewForm(string filename)
{
previewimage = new Bitmap(Image.FromFile(filename));
pictureBox1.Image = previewimage;
}
public void ApplyFilter()
{
Bitmap bit;
bit = new Bitmap(previewimage);if(brightness had been changed)
{
BrightnessFilter(bit, brightness_value);
}
If(contrast had been changed)
{
ContrastFilter(bit, contrast_value);
}
PictureBox.Image = bit;}
I could apply all filters every time when I changing some trackbar but it really decrease program performance..
All you need to do, is start with the image already in the picture box, then apply your filter to that. How are you doing the brightness and contrast ? If you're using a matrix, you can combine the two matrices and do the operations together in one pass. That would also make a lot of sense, speed wise
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.