【发布时间】:2015-07-09 08:34:19
【问题描述】:
为了准备好处理 bmp 图像并能够对其执行算术运算,应遵循什么程序?
例如,如果我有image1.bmp 和image2.bmp 并且我想获得某种校正因子,那么我需要执行诸如
mean(image1/image2)*image1
我唯一能想到的就是以某种方式将图像放入数组中,但我不明白如何加载图像并将其放入数组中。
它会是一个数组吗?还是矩阵?
不胜感激。
【问题讨论】:
为了准备好处理 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 的颜色),我不知道某些操作是否有意义......我知道的还不够关于图像处理来回答这个问题。
【讨论】: