版权声明:本文为博主原创文章,转载请在显著位置标明本文出处以及作者网名,未经作者允许不得用于商业目的。
3、逆反(底片)
算法:
原图像:颜色值color=(R,G,B)
新图像:
RNew=255-R
GNew=255-G
BNew=255-B
color=(RNew,GNew,BNew)
'逆反
Private Sub btnInversion_Click(sender As Object, e As EventArgs) Handles btnInversion.Click
Dim pSourceColor As Color
Dim pDestColor As Color
Dim destImg As New Bitmap(sourceImg.Width, sourceImg.Height)
Dim R, G, B As Integer
For i As Integer = 0 To sourceImg.Width - 1
For j As Integer = 0 To sourceImg.Height - 1
pSourceColor = sourceImg.GetPixel(i, j)
R = pSourceColor.R
G = pSourceColor.G
B = pSourceColor.B
R = 255 - R
G = 255 - G
B = 255 - B
pDestColor = Color.FromArgb(R, G, B)
destImg.SetPixel(i, j, pDestColor)
Next
Next
picDest.Image = destImg
End Sub
处理结果如下:
4、曝光
算法:先定义一个阈值,通常取得是128
原图像:颜色值color=(R,G,B)
新图像:
如果R<阈值,那么RNew=255-R
如果G<阈值,那么GNew=255-G
如果B<阈值,那么BNew=255-B
color=(RNew,GNew,BNew)
'曝光
Private Sub btnExposure_Click(sender As Object, e As EventArgs) Handles btnExposure.Click
Dim pSourceColor As Color
Dim pDestColor As Color
Dim destImg As New Bitmap(sourceImg.Width, sourceImg.Height)
Dim R, G, B As Integer
For i As Integer = 0 To sourceImg.Width - 1
For j As Integer = 0 To sourceImg.Height - 1
pSourceColor = sourceImg.GetPixel(i, j)
R = pSourceColor.R
G = pSourceColor.G
B = pSourceColor.B
If R < 128 Then R = 255 - R
If G < 128 Then G = 255 - G
If B < 128 Then B = 255 - B
pDestColor = Color.FromArgb(R, G, B)
destImg.SetPixel(i, j, pDestColor)
Next
Next
picDest.Image = destImg
End Sub
处理结果如下:
由于.net平台下C#和vb.NET很相似,本文也可以为C#爱好者提供参考。
学习更多vb.net知识,请参vb.net教程目录
————————————————
版权声明:本文为CSDN博主「VB.Net」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。