首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bmp图像处理

Bmp图像处理
EN

Stack Overflow用户
提问于 2015-07-09 08:34:19
回答 1查看 52关注 0票数 0

为了使bmp图像能够被操纵,并且能够和它们一起执行aritmethic操作,应该遵循什么步骤?

例如,如果我有image1.bmpimage2.bmp,我想得到某种校正因子,所以我需要执行一些操作,例如

mean(image1/image2)*image1

我唯一能想到的就是以某种方式将图像放入数组中,但我无法理解如何加载图像并将其放入数组。

它会是一个数组吗?还是矩阵?

如果能帮上忙就好了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-09 09:02:01

这是我的刺刀。希望能帮上忙。

代码语言:javascript
复制
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的颜色),我不知道某些操作是否有意义.我对图像处理的了解还不足以回答这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31312226

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档