Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Image Brightness and Contrast change together

Image Brightness and Contrast change together

Scheduled Pinned Locked Moved C#
helptutorialgraphicsperformance
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lexx_zone
    wrote on last edited by
    #1

    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..

    C 1 Reply Last reply
    0
    • L lexx_zone

      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..

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups