bmp图像处理
Bmp image manipulation
要准备好要处理的 bmp 图像并能够对其执行算术运算,需要遵循什么程序?
例如,如果我有 image1.bmp
和 image2.bmp
并且我想获得某种校正因子,那么我需要执行诸如
之类的操作
mean(image1/image2)*image1
我唯一能想到的就是以某种方式将图像放入数组中,但我不明白如何加载图像并将其放入数组中。
它会是一个数组吗?还是矩阵?
如有任何帮助,我们将不胜感激。
这是我的尝试。希望对你有帮助。
Sub Main(filePath1 As String, filePath2 As String, filePath3 As String)
Dim bmpImage1 As New Drawing.Bitmap(filePath1)
Dim bmpImage2 As New Drawing.Bitmap(filePath2)
Dim bmpImage3 As New Drawing.Bitmap(filePath3)
Dim resultBmpImage As New Drawing.Bitmap(bmpImage1.Width, bmpImage1.Height)
'Iterate through every pixel:
For x As Integer = 0 To bmpImage1.Width - 1
For y As Integer = 0 To bmpImage1.Height - 1
Dim processedColor As System.Drawing.Color =
ProcessColor(
bmpImage1.GetPixel(x, y),
bmpImage2.GetPixel(x, y),
bmpImage3.GetPixel(x, y))
resultBmpImage.SetPixel(x, y, processedColor)
Next
Next
End Sub
Private Function ProcessColor(
color1 As System.Drawing.Color,
color2 As System.Drawing.Color,
color3 As System.Drawing.Color) As System.Drawing.Color
Dim resultGrayLevel As Integer = (color1.R / color2.R) + color3.R
Dim color As System.Drawing.Color = System.Drawing.Color.FromArgb(255, resultGrayLevel, resultGrayLevel, resultGrayLevel)
Return color
End Function
问题是:如果我们不是在谈论灰度颜色(即:R=G=B 的颜色),我不知道某些操作是否有意义...我不知道足够了解图像处理来回答这个问题。
要准备好要处理的 bmp 图像并能够对其执行算术运算,需要遵循什么程序?
例如,如果我有 image1.bmp
和 image2.bmp
并且我想获得某种校正因子,那么我需要执行诸如
mean(image1/image2)*image1
我唯一能想到的就是以某种方式将图像放入数组中,但我不明白如何加载图像并将其放入数组中。
它会是一个数组吗?还是矩阵?
如有任何帮助,我们将不胜感激。
这是我的尝试。希望对你有帮助。
Sub Main(filePath1 As String, filePath2 As String, filePath3 As String)
Dim bmpImage1 As New Drawing.Bitmap(filePath1)
Dim bmpImage2 As New Drawing.Bitmap(filePath2)
Dim bmpImage3 As New Drawing.Bitmap(filePath3)
Dim resultBmpImage As New Drawing.Bitmap(bmpImage1.Width, bmpImage1.Height)
'Iterate through every pixel:
For x As Integer = 0 To bmpImage1.Width - 1
For y As Integer = 0 To bmpImage1.Height - 1
Dim processedColor As System.Drawing.Color =
ProcessColor(
bmpImage1.GetPixel(x, y),
bmpImage2.GetPixel(x, y),
bmpImage3.GetPixel(x, y))
resultBmpImage.SetPixel(x, y, processedColor)
Next
Next
End Sub
Private Function ProcessColor(
color1 As System.Drawing.Color,
color2 As System.Drawing.Color,
color3 As System.Drawing.Color) As System.Drawing.Color
Dim resultGrayLevel As Integer = (color1.R / color2.R) + color3.R
Dim color As System.Drawing.Color = System.Drawing.Color.FromArgb(255, resultGrayLevel, resultGrayLevel, resultGrayLevel)
Return color
End Function
问题是:如果我们不是在谈论灰度颜色(即:R=G=B 的颜色),我不知道某些操作是否有意义...我不知道足够了解图像处理来回答这个问题。