以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]图片亮度和对比度问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=65446) |
|||||
-- 作者:pcxjxjhkw -- 发布时间:2015/3/16 16:42:00 -- [求助]图片亮度和对比度问题 1.如何调整图片的亮度和对比度。 2.如何将图片去色,变成黑白。
|
|||||
-- 作者:Bin -- 发布时间:2015/3/16 17:06:00 -- http://www.shangxueba.com/jingyan/t65496.html |
|||||
-- 作者:有点甜 -- 发布时间:2015/3/16 17:58:00 -- 亮度
Dim degree As Integer = 50 \'-255 到 255 Dim offset As Integer = bmpData.Stride - bmpData.Width * 4 Pic.UnlockBits(bmpData)
----------------
对比度
Dim degree As Integer = -20 \'-100 到 100 Dim contrast As Double = (100 + degree) / 100.0 Dim Width As Integer, Height As Integer Dim offset As Integer = bmpData.Stride - bmpData.Width * 4 Pic.UnlockBits(bmpData) |
|||||
-- 作者:有点甜 -- 发布时间:2015/3/16 17:59:00 -- 汗...对图片处理不熟...... |
|||||
-- 作者:lyfxybc -- 发布时间:2015/3/16 18:26:00 -- 从网上找了个调亮度的代码,不知如何用 \'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \'Author: Larry Nung \'Date: 2009/6/2 \'File: \'Memo: \'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| \'\'\' <summary> \'\'\' \'\'\' </summary> \'\'\' <remarks></remarks> Public Class Form1
\'***************************************************************************
\'Author: Larry Nung
\'Date: 2009/6/2
\'Purpose:
\'Memo:
\'***************************************************************************
\'\'\' <summary>
\'\'\' Handles the Click event of the btnLoad control.
\'\'\' </summary>
\'\'\' <param name="sender">The source of the event.</param>
\'\'\' <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
\'\'\' <remarks></remarks> Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Me.PictureBox1.Image = New Bitmap(OpenFileDialog1.FileName) End If End Sub
\'***************************************************************************
\'Author: Larry Nung
\'Date: 2009/6/2
\'Purpose:
\'Memo:
\'***************************************************************************
\'\'\' <summary>
\'\'\' Brights the bitmap.
\'\'\' </summary>
\'\'\' <param name="bmp">The BMP.</param>
\'\'\' <param name="brighValue">The brigh value.</param>
\'\'\' <remarks></remarks> Private Function BrightBitmap(ByVal bmp As Bitmap, ByVal brighValue As Integer) As Bitmap For x As Integer = 0 To bmp.Width - 1 For y As Integer = 0 To bmp.Height - 1 Dim color As Color = bmp.GetPixel(x, y) Dim r As Integer = If(color.R + brighValue > 255, 255, color.R + brighValue) Dim g As Integer = If(color.G + brighValue > 255, 255, color.G + brighValue) Dim b As Integer = If(color.B + brighValue > 255, 255, color.B + brighValue) bmp.SetPixel(x, y, color.FromArgb(r, g, b))
Next
Next
Return bmp End Function
\'***************************************************************************
\'Author: Larry Nung
\'Date: 2009/6/3
\'Purpose:
\'Memo:
\'***************************************************************************
\'\'\' <summary>
\'\'\' Handles the Click event of the btnBright control.
\'\'\' </summary>
\'\'\' <param name="sender">The source of the event.</param>
\'\'\' <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
\'\'\' <remarks></remarks> Private Sub btnBright_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBright.Click PictureBox1.Image = BrightBitmap(DirectCast(PictureBox1.Image, Bitmap), TrackBar1.Value) End Sub End Class
图片旋转
[此贴子已经被作者于2015/3/16 18:36:37编辑过]
|
|||||
-- 作者:有点甜 -- 发布时间:2015/3/16 18:59:00 -- 看3楼 |
|||||
-- 作者:pcxjxjhkw -- 发布时间:2015/3/17 16:13:00 -- 1.如何获取当前图片的亮度和对比度值? 2.如何将当前图片由彩色变成黑白?
|
|||||
-- 作者:有点甜 -- 发布时间:2015/3/17 16:26:00 -- 1、你用变量记录
2、
Dim offset As Integer = bmpData.Stride - bmpData.Width * 4 Dim R As Integer = Marshal.ReadByte(ptr, 0) ptr = CType(ptr.ToInt32 + 4, IntPtr) Pic.UnlockBits(bmpData)
|