在pictureBox中调整图像亮度和对比度,有什么方法?

解决方案 »

  1.   

    和picturebox一点关系都没有.
    图象的色调你编写程序去对图象进行处理.
      

  2.   

    pictureBox本身是没有这个功能的,建议使用GDI+来实现。
    可以参考http://www.codeproject.com/script/Articles/list_articles.asp?userid=6556
    这里的GDI+文章来实现。
    Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters
    The first in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 2 - Convolution Filters
    The second in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 3 - Edge Detection Filters
    The third in a series of articles which will build an image processing library in C# and GDI+ Image Processing for Dummies with C# and GDI+ Part 4 - Bilinear Filters and Resizing
    The fourth installment covers how to write a filter that resizes an image, and uses bilinear filtering Image Processing for Dummies with C# and GDI+ Part 5 - Displacement filters, including swirl
    In the fifth installment, we build a framework for generating filters that work by changing a pixel's location, rather than colour. Image Processing for Dummies with C# and GDI+ Part 6 - The HSL color space
    A discussion of the HSL color space, including code for a color picker and image filters
      

  3.   

    試下這樣可以嗎
    if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
    {
    bmp=new Bitmap(this.openFileDialog1.FileName);
    for (int i=0;i<bmp.Width-1;i++)
    {
    for(int j=0;j<bmp.Height-1;j++)
    {
    Color Color1=bmp.GetPixel(i,j);
    Color Color2=bmp.GetPixel(i+1,j+1);
    int red=Math.Abs(Color1.R-Color2.R+128);
    int green=Math.Abs(Color1.G-Color2.G+128);
    int blue=Math.Abs(Color1.B-Color2.B+128);
    //晇伎揭燴
    if(red>255) red=255;
    if(red<0) red=0; if(green>255) green=255;
    if(green<0) green=0; if(blue>255) blue=255;
    if(blue<0) blue=0;
    bmp.SetPixel(i,j,Color.FromArgb(red,green,blue));
    }
    }
    this.pictureBox1.Image=bmp;
    }
    此代碼可以改變圖片顯示.你可以擴展為你所需要的
      

  4.   

    参考 FotoVision
    http://msdn.microsoft.com/smartclient/codesamples/fotovision/default.aspx
      

  5.   

    agree upto... reusable classes such as PhotoHelper that contains methods to adjust the brightness, contrast, saturation, gamma, convert to grayscale and sepia, rotate, flip, resize and crop images.
      

  6.   

    谢谢dragonfly001;我已经解决了亮度的问题,还有个对比度的算法有人能提供一下吗?
      

  7.   

    private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    Bitmap bmp=(Bitmap)this.pictureBox1.Image;
    try 
    {Color pixelColor=bmp.GetPixel(e.X,e.Y);
    this.Text="("+pixelColor.R.ToString()+","+
    pixelColor.G.ToString()+","+pixelColor.B.ToString()+")";
    }
    catch {}

    }
    這段代碼可以獲得圖片上任意點的RGB信息.
      

  8.   

    TO: dragonfly001(我思考,我生存!) 
    這樣做的處理速度非常的慢,你可以考慮用CopyMemery API函數把圖像的像素二進制數據讀取出來,然後再作處理。