首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ILNumerics曲面图中的颜色范围

ILNumerics曲面图中的颜色范围
EN

Stack Overflow用户
提问于 2014-07-23 21:40:14
回答 2查看 235关注 0票数 1

我正在使用ILNumerics生成一个曲面图。

我想使用一个平面阴影彩色地图(即颜色范围),而不是平滑的阴影彩色地图(即每个像素有自己的颜色)。

这与ILNumerics是可能的吗?

平阴影曲面图和色条图例:

光滑阴影曲面图和色条图例的示例:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-07-27 21:16:25

您可以创建一个显示平面阴影行为的彩色地图。只需复制公共颜色图中存在的关键点,就可以对获得相同颜色分配的颜色数据范围进行建模。

平板遮阳鞋垫是如何工作的

根据文档,共垫的关键点由5列组成:一个“位置”和4个颜色值(RGBA)。为了模拟一个“平的”阴影彩色地图,放置两个关键点“几乎”完全在对方之上,给第一个颜色的下一个较低的范围和第二个颜色的下一个更高的范围。因此,颜色范围由具有相同颜色分配的两个关键点建模。

我在上面的段落中写了“几乎”,因为我认为你必须至少在两个范围的边缘之间留下一个很小的空白--希望没有实际的颜色数据值会达到这一差距。但是看起来,根本不需要缺口,我们可以给出两个关键点完全相同的值。但是在排序时要小心:不要混合颜色( ILMath.sort()中的快速排序不稳定!)

在下面的示例中,将从Colormaps.Jet创建一个平面阴影彩色映射:

代码语言:javascript
复制
Keypoints for Colormaps.Jet (original, interpolating)
<Single> [6,5]
[0]:          0          0          0     0,5625          1 
[1]:     0,1094          0          0     0,9375          1 
[2]:     0,3594          0     0,9375          1          1 
[3]:     0,6094     0,9375          1     0,0625          1 
[4]:     0,8594          1     0,0625          0          1 
[5]:          1     0,5000          0          0          1 

由它衍生而来的平面阴影版本:

代码语言:javascript
复制
Colormaps.Jet - flat shading version
<Single> [11,5]
[0]:          0          0          0     0,5625          1 
[1]:     0,1094          0          0     0,5625          1 
[2]:     0,1094          0          0     0,9375          1 
[3]:     0,3594          0          0     0,9375          1 
[4]:     0,3594          0     0,9375          1          1 
[5]:     0,6094          0     0,9375          1          1 
[6]:     0,6094     0,9375          1     0,0625          1 
[7]:     0,8594     0,9375          1     0,0625          1 
[8]:     0,8594          1     0,0625          0          1 
[9]:     1,0000          1     0,0625          0          1 
[10]:          1     0,5000          0          0          1 

正如您很容易看到的,我在CreateFlatShadedColormap()中犯了一个错误:最后一个带有(0.5,0,0,1)的keypoint将永远不会被使用。我会把它作为一个练习来解决.;)

全平阴影示例

代码语言:javascript
复制
private void ilPanel1_Load(object sender, EventArgs e) {
    ILArray<float> A = ILMath.tosingle(ILSpecialData.terrain["0:400;0:400"]);
    // derive a 'flat shaded' colormap from Jet colormap
    var cm = new ILColormap(Colormaps.Jet);
    ILArray<float> cmData = cm.Data;
    cmData.a = Computation.CreateFlatShadedColormap(cmData);
    cm.SetData(cmData); 
    // display interpolating colormap
    ilPanel1.Scene.Add(new ILPlotCube() { 
        Plots = {
            new ILSurface(A, colormap: Colormaps.Jet) {
                Children = { new ILColorbar() },
                Wireframe = { Visible = false }
            }
        }, 
        ScreenRect = new RectangleF(0,-0.05f,1,0.6f)
    }); 

    // display flat shading colormap
    ilPanel1.Scene.Add(new ILPlotCube() {
        Plots = {
            new ILSurface(A, colormap: cm) {
                Children = { new ILColorbar() },
                Wireframe = { Visible = false }
            }
        },
        ScreenRect = new RectangleF(0, 0.40f, 1, 0.6f)
    }); 

}

private class Computation : ILMath {
    public static ILRetArray<float> CreateFlatShadedColormap(ILInArray<float> cm) {
        using (ILScope.Enter(cm)) {
            // create array large enough to hold new colormap
            ILArray<float> ret = zeros<float>(cm.S[0] * 2 - 1, cm.S[1]);
            // copy the original
            ret[r(0, cm.S[0] - 1), full] = cm; 
            // double original keypoints, give small offset (may not even be needed?) 
            ret[r(cm.S[0], end), 0] = cm[r(1, end), 0] - epsf;
            ret[r(cm.S[0], end), r(1, end)] = cm[r(0, end - 1), r(1, end)];
            // reorder to sort keypoints in ascending order
            ILArray<int> I = 1;
            sort(ret[full, 0], Indices: I);
            return ret[I, full];
        }

    }

结果

票数 1
EN

Stack Overflow用户

发布于 2014-07-27 16:17:59

这是不可能的ILNumerics中的曲面图总是在网格点之间插入颜色。对于其他阴影模型,您必须创建自己的表面类。

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

https://stackoverflow.com/questions/24921536

复制
相关文章

相似问题

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