/// <summary> /// create new color enumeration based on a specific colormap /// </summary> /// <param name="basemap"></param> public ILColorEnumerator(Colormaps basemap) { ILColormap cm = new ILColormap(basemap); m_colors = new List <Color>(); for (int i = 0; i < cm.Length; i++) { m_colors.Add(cm.Map(i)); } m_curPos = 0; }
private void create(ILBaseArray data, Colormaps colormap) { ILArray <float> dataF = ILNumerics.BuiltInFunctions.ILMath.tosingle(data); m_boxes = new ILLitBox3D[data.Dimensions[0], data.Dimensions[1]]; float maxY = data.Dimensions[0] * (m_barLengthY + m_paddingY); // prepare coloring for top quads ILColormap cmap = new ILColormap(colormap); float minV, maxV, mult; dataF.GetLimits(out minV, out maxV); if (maxV > minV) { mult = (cmap.Length - 1) / (maxV - minV); } else { minV = 0; mult = 0; } for (int r = 0; r < data.Dimensions[0]; r++) { for (int c = 0; c < data.Dimensions[1]; c++) { float val = dataF.GetValue(r, c); ILPoint3Df max = new ILPoint3Df( (float)(c * (m_paddingX + m_barLengthX) + m_barLengthX) , (float)(maxY - r * (m_paddingY + m_barLengthY)) , val); ILPoint3Df min = new ILPoint3Df( max.X - m_barLengthX , max.Y - m_barLengthY , 0); Color topColor = cmap.Map((double)(val - minV) * mult); ILLitBox3D box = new ILLitBox3D(m_panel, min, max, m_barColor, topColor); box.GradientColor = m_barColorGradient; box.TopLabel.Color = topColor; box.TopLabel.Text = ""; m_boxes[r, c] = box; Add(box); } } }
/// <summary> /// create specific colormap /// </summary> /// <param name="map"></param> public ILColormap (Colormaps map) { m_map = MapCreator.CreateMap(map,128); m_type = map; }
/// <summary> /// construct new colormap, based on HLS model /// </summary> internal ILColormap () { m_map = MapCreator.CreateMap(Colormaps.Hsv); m_type = Colormaps.Hsv; }
/// <summary> /// create colormap /// </summary> /// <param name="map">map specification</param> /// <param name="len">len of colormap</param> /// <returns>colormap (matrix with size [len,3])</returns> internal static ILArray<float> CreateMap(Colormaps map, int len) { ILArray<float> ret = null; ILArray<double> retd; // helper var int n; switch (map) { case Colormaps.Autumn: ret = tosingle(horzcat(ones(len,1),linspace(0,1.0,len).T,zeros(len,1))); break; case Colormaps.Bone: ret = CreateMap( Colormaps.Hot)[":;end:-1:0"]; ret = (tosingle(repmat(linspace(0,1.0,len).T,1,3)*7.0) + ret)/8.0f; break; case Colormaps.Colorcube: throw new NotImplementedException("ILColormap: sorry, colorcube must be implemented!"); break; case Colormaps.Cool: retd = horzcat(linspace(0,1.0,len).T,linspace(1.0,0.0,len).T,ones(len,1)); ret = tosingle(retd); break; case Colormaps.Copper: retd = linspace(0,1.0,len).T; ret = ILArray<float>.empty(); ret = tosingle(min(1.0,retd*1.25)); ret[":;1"] = tosingle(retd*0.782); ret[":;2"] = tosingle(retd*0.4975); break; case Colormaps.Flag: retd = new double[,]{{1, 0, 0},{1, 1, 1},{0, 0, 1},{0, 0, 0}}; retd = repmat(retd.T,(int)ceil((double)len/retd.Dimensions[1]),1); ret = tosingle(retd[vector(0,len-1),null]); break; case Colormaps.Gray: ret = tosingle(repmat(linspace(0,1.0,len).T,1,3)); break; case Colormaps.Hot: n = (int)fix(len/8.0*3); retd = zeros(len,3); ILArray<double> rng = vector(0,n-1); retd[rng,0] = linspace (0,1.0,n); retd[vector(n,len-1),0] = 1.0; retd[rng+n,1] = linspace (0,1.0,n); retd[vector(2*n,len-1),1] = 1.0; rng = vector(len-2*n,len-1); retd[rng,2] = linspace (0,1.0,rng.Length); ret = tosingle(retd); break; case Colormaps.Hsv: n = len / 6; // red ILArray<double> peak = 2.0-abs(linspace(2,-2,4*n)); retd = zeros(len,3); retd[vector(len - peak.Length,len-1),0] = peak; retd[vector(0 ,4*n-1),1] = peak; retd[vector(0 ,2*n-1),2] = peak[vector(2*n,4*n-1)]; retd[vector(len - 2*n,len-1),2] = peak[vector(0 ,2*n-1)]; retd[retd > 1] = 1; ret = tosingle(retd); break; case Colormaps.ILNumerics: ret = new ILArray<float>(len,3); int tmp; ILColorProvider cprov = new ILColorProvider(0.0f,0.5f,1.0f); rng = linspace(ILColorProvider.MAXHUEVALUE,0.0,len); for (int i = 0; i < len; i++) { tmp = cprov.H2RGB((float)rng[i]); ret.SetValue((float)(tmp>>16 & 255),i,0); ret.SetValue((float)(tmp>>8 & 255),i,1); ret.SetValue((float)(tmp & 255),i,2); } ret /= 255.0f; break; case Colormaps.Jet: n = len / 8; // red peak = 1.5-abs(linspace(1.5,-1.5,6*n)); retd = zeros(len,3); retd[vector(0 ,5*n-1),0] = peak[vector(n,6*n-1)]; retd[vector(n ,7*n-1),1] = peak; retd[vector(3*n,8*n-1),2] = peak[vector(0,5*n-1)]; retd[retd > 1] = 1; ret = tosingle(retd); break; case Colormaps.Lines: retd = randn(len,3); retd /= maxall(abs(retd)); ret = tosingle(1.0-abs(retd)); break; case Colormaps.Pink: ret = CreateMap(Colormaps.Hot,len); ret = sqrt((repmat(tosingle(linspace(0,1.0,len).T),1,3)*2.0f + ret)/3.0f); break; case Colormaps.Prism: retd = new double[,]{{1, 0, 0},{1, 0.5, 0},{1, 1, 0},{0, 1, 0},{0, 0, 1},{2/3.0, 0, 1}}; retd = repmat(retd.T,(int)ceil((double)len/retd.Dimensions[1]),1); ret = tosingle(retd[vector(0,len-1),null]); break; case Colormaps.Spring: retd = ones(len,1); retd[":;1"] = linspace(0.0,1.0,len); retd[":;2"] = linspace(1.0,0.0,len); ret = tosingle(retd); break; case Colormaps.Summer: retd = linspace(0.0,1.0,len).T; retd[":;1"] = 0.5+retd/2.0;; retd[":;2"] = ones(len,1)*0.4; ret = tosingle(retd); break; case Colormaps.White: ret = tosingle(ones(len,3)); break; case Colormaps.Winter: retd = zeros(len,1); retd[":;2"] = 0.5+(1.0-linspace(0.0,1.0,len))/2.0; retd[":;1"] = linspace(0.0,1.0,len); ret = tosingle(retd); break; } return ret; }
/// <summary> /// create colorpam of length 128 /// </summary> /// <param name="map">map specification</param> /// <returns>colormap (matrix with size [len,3])</returns> internal static ILArray<float> CreateMap(Colormaps map) { return CreateMap(map,128); }
/// <summary> /// create colormap based on predefined colors /// </summary> /// <param name="colors"></param> public ILColormap (ILArray<float> colors) { m_map = colors.R; m_type = Colormaps.ILNumerics; }
/// <summary> /// construct new colormap, based on HLS model /// </summary> internal ILColormap() { m_map = MapCreator.CreateMap(Colormaps.Hsv); m_type = Colormaps.Hsv; }
/// <summary> /// create colormap /// </summary> /// <param name="map">map specification</param> /// <param name="len">len of colormap</param> /// <returns>colormap (matrix with size [len,3])</returns> internal static ILArray <float> CreateMap(Colormaps map, int len) { ILArray <float> ret = null; ILArray <double> retd; // helper var int n; switch (map) { case Colormaps.Autumn: ret = tosingle(horzcat(ones(len, 1), linspace(0, 1.0, len).T, zeros(len, 1))); break; case Colormaps.Bone: ret = CreateMap(Colormaps.Hot)[":;end:-1:0"]; ret = (tosingle(repmat(linspace(0, 1.0, len).T, 1, 3) * 7.0) + ret) / 8.0f; break; case Colormaps.Colorcube: throw new NotImplementedException("ILColormap: sorry, colorcube must be implemented!"); break; case Colormaps.Cool: retd = horzcat(linspace(0, 1.0, len).T, linspace(1.0, 0.0, len).T, ones(len, 1)); ret = tosingle(retd); break; case Colormaps.Copper: retd = linspace(0, 1.0, len).T; ret = ILArray <float> .empty(); ret = tosingle(min(1.0, retd * 1.25)); ret[":;1"] = tosingle(retd * 0.782); ret[":;2"] = tosingle(retd * 0.4975); break; case Colormaps.Flag: retd = new double[, ] { { 1, 0, 0 }, { 1, 1, 1 }, { 0, 0, 1 }, { 0, 0, 0 } }; retd = repmat(retd.T, (int)ceil((double)len / retd.Dimensions[1]), 1); ret = tosingle(retd[vector(0, len - 1), null]); break; case Colormaps.Gray: ret = tosingle(repmat(linspace(0, 1.0, len).T, 1, 3)); break; case Colormaps.Hot: n = (int)fix(len / 8.0 * 3); retd = zeros(len, 3); ILArray <double> rng = vector(0, n - 1); retd[rng, 0] = linspace(0, 1.0, n); retd[vector(n, len - 1), 0] = 1.0; retd[rng + n, 1] = linspace(0, 1.0, n); retd[vector(2 * n, len - 1), 1] = 1.0; rng = vector(len - 2 * n, len - 1); retd[rng, 2] = linspace(0, 1.0, rng.Length); ret = tosingle(retd); break; case Colormaps.Hsv: n = len / 6; // red ILArray <double> peak = 2.0 - abs(linspace(2, -2, 4 * n)); retd = zeros(len, 3); retd[vector(len - peak.Length, len - 1), 0] = peak; retd[vector(0, 4 * n - 1), 1] = peak; retd[vector(0, 2 * n - 1), 2] = peak[vector(2 * n, 4 * n - 1)]; retd[vector(len - 2 * n, len - 1), 2] = peak[vector(0, 2 * n - 1)]; retd[retd > 1] = 1; ret = tosingle(retd); break; case Colormaps.ILNumerics: ret = new ILArray <float>(len, 3); int tmp; ILColorProvider cprov = new ILColorProvider(0.0f, 0.5f, 1.0f); rng = linspace(ILColorProvider.MAXHUEVALUE, 0.0, len); for (int i = 0; i < len; i++) { tmp = cprov.H2RGB((float)rng[i]); ret.SetValue((float)(tmp >> 16 & 255), i, 0); ret.SetValue((float)(tmp >> 8 & 255), i, 1); ret.SetValue((float)(tmp & 255), i, 2); } ret /= 255.0f; break; case Colormaps.Jet: n = len / 8; // red peak = 1.5 - abs(linspace(1.5, -1.5, 6 * n)); retd = zeros(len, 3); retd[vector(0, 5 * n - 1), 0] = peak[vector(n, 6 * n - 1)]; retd[vector(n, 7 * n - 1), 1] = peak; retd[vector(3 * n, 8 * n - 1), 2] = peak[vector(0, 5 * n - 1)]; retd[retd > 1] = 1; ret = tosingle(retd); break; case Colormaps.Lines: retd = randn(len, 3); retd /= maxall(abs(retd)); ret = tosingle(1.0 - abs(retd)); break; case Colormaps.Pink: ret = CreateMap(Colormaps.Hot, len); ret = sqrt((repmat(tosingle(linspace(0, 1.0, len).T), 1, 3) * 2.0f + ret) / 3.0f); break; case Colormaps.Prism: retd = new double[, ] { { 1, 0, 0 }, { 1, 0.5, 0 }, { 1, 1, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 2 / 3.0, 0, 1 } }; retd = repmat(retd.T, (int)ceil((double)len / retd.Dimensions[1]), 1); ret = tosingle(retd[vector(0, len - 1), null]); break; case Colormaps.Spring: retd = ones(len, 1); retd[":;1"] = linspace(0.0, 1.0, len); retd[":;2"] = linspace(1.0, 0.0, len); ret = tosingle(retd); break; case Colormaps.Summer: retd = linspace(0.0, 1.0, len).T; retd[":;1"] = 0.5 + retd / 2.0;; retd[":;2"] = ones(len, 1) * 0.4; ret = tosingle(retd); break; case Colormaps.White: ret = tosingle(ones(len, 3)); break; case Colormaps.Winter: retd = zeros(len, 1); retd[":;2"] = 0.5 + (1.0 - linspace(0.0, 1.0, len)) / 2.0; retd[":;1"] = linspace(0.0, 1.0, len); ret = tosingle(retd); break; } return(ret); }
/// <summary> /// create colorpam of length 128 /// </summary> /// <param name="map">map specification</param> /// <returns>colormap (matrix with size [len,3])</returns> internal static ILArray <float> CreateMap(Colormaps map) { return(CreateMap(map, 128)); }
/// <summary> /// create colormap based on predefined colors /// </summary> /// <param name="colors"></param> public ILColormap(ILArray <float> colors) { m_map = colors.R; m_type = Colormaps.ILNumerics; }
/// <summary> /// create specific colormap /// </summary> /// <param name="map"></param> public ILColormap(Colormaps map) { m_map = MapCreator.CreateMap(map, 128); m_type = map; }
private void create(ILBaseArray data, Colormaps colormap) { ILArray<float> dataF = ILNumerics.BuiltInFunctions.ILMath.tosingle(data); m_boxes = new ILLitBox3D[data.Dimensions[0],data.Dimensions[1]]; float maxY = data.Dimensions[0] * (m_barLengthY + m_paddingY); // prepare coloring for top quads ILColormap cmap = new ILColormap(colormap); float minV,maxV,mult; dataF.GetLimits(out minV, out maxV); if (maxV > minV) { mult = (cmap.Length - 1) / (maxV - minV); } else { minV = 0; mult = 0; } for (int r = 0; r < data.Dimensions[0]; r++) { for (int c = 0; c < data.Dimensions[1]; c++) { float val = dataF.GetValue(r, c); ILPoint3Df max = new ILPoint3Df( (float)(c * (m_paddingX + m_barLengthX) + m_barLengthX) , (float)(maxY - r * (m_paddingY + m_barLengthY)) , val); ILPoint3Df min = new ILPoint3Df( max.X - m_barLengthX , max.Y - m_barLengthY , 0); Color topColor = cmap.Map((double)(val - minV) * mult); ILLitBox3D box = new ILLitBox3D(m_panel,min,max,m_barColor,topColor); box.GradientColor = m_barColorGradient; box.TopLabel.Color = topColor; box.TopLabel.Text = ""; m_boxes[r, c] = box; Add(box); } } }