我试着转换Black&白色图像使用RGB颜色矩阵彩色图像 [英] I'm Try to convert Black & White image to color image using matrixs of RGB colors

查看:121
本文介绍了我试着转换Black&白色图像使用RGB颜色矩阵彩色图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Here is my simple code but it give me nothing altho the RGB values are in the program:
'-------------------------------------Picture color change--------------------
        Dim bm As Bitmap = New Bitmap("C:\trash\Babymono100.bmp")

        Dim x

        Dim y

        For y = 0 To bm.Height - 1

            For x = 0 To bm.Width - 1

                Dim c As Color = bm.GetPixel(x, y)

                TextBox1.Text = c.R

                For i = 1 To 10000


                    If c.R = DataGridViewGray.Rows(i).Cells(1).Value Then
                        bm.SetPixel(x, y, Color.FromArgb(DataGridViewRed.Rows(i).Cells(1).Value, DataGridViewGreen.Rows(i).Cells(1).Value, DataGridViewBlue.Rows(i).Cells(1).Value))

                        Exit For
                    End If

                Next
            Next
        Next
        PictureBox1.Image = bm



'我已经有4种不同的DataGridView for GrayScale,红色,绿色和蓝色

我只需要确定与所选GrayScale颜色相关的3 RGB颜色


'I have Already 4 different DataGridView for GrayScale,Red,Green and Blue colors
I just need to determine the 3 RGB color related to the selected GrayScale color

推荐答案

1。你有一个黑白图像,这意味着所有的R,G,B值是相等的。

2.你扫描数据网格的10000行,寻找与R值匹配的然后将所有R,G,B值设置为相同的值。

3.它们已经是那个值(见#1)所以这没有做任何事情。

4. R值是一个字节值(0..255)所以超过256行是毫无意义的。



你想要完成某种假颜色映射?

如果是这样,数据网格应该有单独的R,G,B列,并按所需的映射排序,因此可以直接索引而不是搜索。

即行(0)应该在源图像中具有强度== 0(黑色)的假色,

行(1)在源图像中应该具有强度== 1的假色,

...

行(255)应该在源图像中具有强度== 255(白色)的假色。
1. You have a black and white image which means that all of the R,G,B values are equal.
2. You scan the 10000 rows of the data grid looking for a match to the R value and then set all of the R,G,B values to that same value.
3. They already were that value (see #1) so this doesn't do anything.
4. The R value is a byte value (0..255) so more than 256 rows is pointless.

Are you trying to accomplish some sort of "false color" mapping?
If so, the data grid should have separate R,G,B columns, and be ordered by the desired mapping so it can be indexed directly instead of searching.
I.e. Rows(0) should have the false color for intensity==0 (black) in the source image,
Rows(1) should have the false color for intensity==1 in the source image,
...
Rows(255) should have the false color for intensity==255 (white) in the source image.


这篇关于我试着转换Black&白色图像使用RGB颜色矩阵彩色图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆