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

Image processing problem...

Scheduled Pinned Locked Moved C#
graphicsquestionhelp
4 Posts 3 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.
  • S Offline
    S Offline
    S K Y
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • S S K Y

      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

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

      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

      S 1 Reply Last reply
      0
      • C Christian Graus

        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

        S Offline
        S Offline
        S K Y
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • S S K Y

          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

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          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.


          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