多波段图像光栅到RGB [英] Multi-Band Image raster to RGB

查看:288
本文介绍了多波段图像光栅到RGB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像数据集,它是arff格式的多波段数据集。
它看起来像这样:

I have an image dataset which is a multiband dataset of arff format. It looks like this:

8.3000000e+001  9.3000000e+001  9.6000000e+001  7.5000000e+001 1.0000000e+000 
8.3000000e+001  9.3000000e+001  9.6000000e+001  7.5000000e+001 1.0000000e+000
8.3000000e+001  9.3000000e+001  9.6000000e+001  7.5000000e+001 1.0000000e+000
8.3000000e+001  9.3000000e+001  9.6000000e+001  7.5000000e+001  1.0000000e+000
7.4000000e+001  8.4000000e+001  8.6000000e+001  7.1000000e+001  1.0000000e+000
7.4000000e+001  8.4000000e+001  8.6000000e+001  7.1000000e+001  1.0000000e+000
7.4000000e+001  8.4000000e+001  8.6000000e+001  7.1000000e+001  1.0000000e+000
7.4000000e+001  8.4000000e+001  8.6000000e+001  7.1000000e+001  1.0000000e+000

前4个属性指定像素的多波段值,最后一个属性指定类标签。是否可以将其转换为RGB格式?我有java代码根据RGB值对图像进行分类。

The first 4 attributes specify the multiband values of the pixel and last attribute specifies the class label. Is it possible to convert it to RGB format? I have java code to classify an image based on the RGB values.

推荐答案

如果我做得对,那么答案是但只是为了澄清这是我的看法:

If I get it right then the answer is YES but just for clarification this is how I see it:

你有4个波段的强度,你需要 RGB 颜色值从中。最后一个数字与颜色无关,所以请忽略它。

You got 4 bands intensities and you need RGB color value from it. Last number is not related to color in any way so ignore it.


  1. 你需要知道什么

如果强度是线性的,如果是非线性的,如何将其转换为线性标度。您需要知道每个使用的波段的波长或 RGB 颜色

if the intensity is linear or not and if nonlinear how to convert it to linear scale. You need to know wavelength or RGB color for each band used

如何转换

获取波段的每个 RGB 并将其乘以线性强度,然后将它们全部加在一起。

take each RGB of band and multiply it by its linear intensity then sum all of them together.

color_rgb = band0_rgb*band0_intensity+...+band3_rgb*band3_intensity


  • 如何从波长获得可用的波段RGB

    获取波长的光的颜色可见光谱的RGB值并重新调整颜色,因此如果您将所有波段添加到相同的强度,您将获得白色。

    obtain color of light of wavelength by RGB values of visible spectrum and rescale the color so if you add all the bands together with same intensity you get white color.

    我使用均匀分布的频段通过可见光谱进行多光谱渲染,这就是我在C ++中的表现方式:

    //---------------------------------------------------------------------------
    //--- multi band rendering --------------------------------------------------
    //---------------------------------------------------------------------------
    const int _Bands=10;                            // number of bands used
    double _Band_RGB[_Bands][3];                    // RGB of each band with white bias correction
    double _Band_Wavelength[_Bands];                // wavelength of each band
    //---------------------------------------------------------------------------
    void wavelength2RGB(double *rgb,double lambda)  // RGB <0,1> <- lambda <400e-9,700e-9> [m]
        {
        double r=0.0,g=0.0,b=0.0,t;
             if ((lambda>=400.0e-9)&&(lambda<410.0e-9)) { t=(lambda-400.0e-9)/(410.0e-9-400.0e-9); r=    +(0.33*t)-(0.20*t*t); }
        else if ((lambda>=410.0e-9)&&(lambda<475.0e-9)) { t=(lambda-410.0e-9)/(475.0e-9-410.0e-9); r=0.14         -(0.13*t*t); }
        else if ((lambda>=545.0e-9)&&(lambda<595.0e-9)) { t=(lambda-545.0e-9)/(595.0e-9-545.0e-9); r=    +(1.98*t)-(     t*t); }
        else if ((lambda>=595.0e-9)&&(lambda<650.0e-9)) { t=(lambda-595.0e-9)/(650.0e-9-595.0e-9); r=0.98+(0.06*t)-(0.40*t*t); }
        else if ((lambda>=650.0e-9)&&(lambda<700.0e-9)) { t=(lambda-650.0e-9)/(700.0e-9-650.0e-9); r=0.65-(0.84*t)+(0.20*t*t); }
             if ((lambda>=415.0e-9)&&(lambda<475.0e-9)) { t=(lambda-415.0e-9)/(475.0e-9-415.0e-9); g=             +(0.80*t*t); }
        else if ((lambda>=475.0e-9)&&(lambda<590.0e-9)) { t=(lambda-475.0e-9)/(590.0e-9-475.0e-9); g=0.8 +(0.76*t)-(0.80*t*t); }
        else if ((lambda>=585.0e-9)&&(lambda<639.0e-9)) { t=(lambda-585.0e-9)/(639.0e-9-585.0e-9); g=0.84-(0.84*t)           ; }
             if ((lambda>=400.0e-9)&&(lambda<475.0e-9)) { t=(lambda-400.0e-9)/(475.0e-9-400.0e-9); b=    +(2.20*t)-(1.50*t*t); }
        else if ((lambda>=475.0e-9)&&(lambda<560.0e-9)) { t=(lambda-475.0e-9)/(560.0e-9-475.0e-9); b=0.7 -(     t)+(0.30*t*t); }
        rgb[0]=r;
        rgb[1]=g;
        rgb[2]=b;
        }
    //---------------------------------------------------------------------------
    double wavelength2int(double lambda)                // white bias correction intensity <0,1+> <- lambda <400e-9,700e-9> [m]
        {                                               // this is mine empirically deduced equation and works for evenly distributed bands
        const double a0=  8.50/double(_swColorWavelengths);// for 3-5 bands low bias, >5 almost no visible bias present
        const double a1=-27.37/double(_swColorWavelengths);
        const double a2=+26.35/double(_swColorWavelengths);
        double t=divide(lambda-400e-9,700e-9-400e-9);
        return (a0)+(a1*t)+(a2*t*t);
        }
    //---------------------------------------------------------------------------
    void init_multiband_colors()                    // init evenly distributed bands through visible spectrum range
        {
        double l,dl; int ix;
        l=405e-9; dl=695e-9; dl=divide(dl-l,_Bands); l+=0.5*dl;
        for (ix=_Bands-1;ix>=0;ix--,l+=dl)          // init colors and wavelengths (multispectral rendering)
            {
            _Band_Wavelength[ix]=l;
            wavelength2RGB(_Band_RGB[ix],l);
            _Band_RGB[ix][0]*=wavelength2int(l);    // white bias removal
            _Band_RGB[ix][1]*=wavelength2int(l);
            _Band_RGB[ix][2]*=wavelength2int(l);
            }
        }
    //---------------------------------------------------------------------------
    //---------------------------------------------------------------------------
    //---------------------------------------------------------------------------
    

    这就是它的样子:

    第一行显示使用过的波段的数量和颜色,第二行是使用多光谱渲染的白色渲染图像的一部分。你可以看到一个小的白色偏见。我将该公式设置为与使用(> = 3)的任意数量的波段一样接近白色。这个想法是,如果你有白噪声(所有频率具有相同的强度),那么你得到一个白色。所以当添加所有使用的乐队颜色时,你应该有白色。所以我根据波长的函数通过经验实验缩放颜色,这就是我想出来的......

    first line shows number and color of used bands the second is part of rendered image in white color using multi spectral rendering. As you can see a small white bias is there. I make that formula to be as close to white as it can be for any number of bands used (>=3). The idea is that if you have white noise (all frequencies with same intensity) then you got a white color. So when add all bands colors used you should have white color. So I empirically experimented with scaling colors by function of wavelength and that is what I came up with ...

    如果你的乐队分布不均匀

    然后你需要整合他们所覆盖的所有均匀分布的乐队,例如:

    Then you need to integrate all evenly distributed bands they cover so for example:


    1. 设置100个波段的颜色

    2. 将它们划分为4个波段到群组

    3. 整合每个群组以获得波段颜色

    4. 将积分乐队的颜色缩放为常用的音阶,如 / = 100

    5. check white bias

    1. set colors for 100 bands
    2. divide them by your 4 bands to groups
    3. integrate each group to obtain band color
    4. scale the integrated band colors to common usable scale like /=100
    5. check white bias

    这篇关于多波段图像光栅到RGB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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