你好, 我正在创建一个软件,该软件将基于该点上的某些值来显示图像的渐变地图.如何创建平滑的颜色渐变以显示像这样的完美地图 ftp.goldensoftware/products/mapviewer/images_m6product/GradientMap.gif [ ^ ] www.georeference/doc/images/sc_surf_data_14.gif [ ^ ] 请向我建议任何示例代码或任何算法,以使值更改看起来像这样....,这将对其他开发此类应用程序的人有所帮助. 我需要这样 i.imgur/GJAEp.png 我仅在该点上绘图,其余区域将填充适当的颜色 在此先感谢...
Hello, I am creating a software that will show a gradiant map for an image based on some value in that points. How I can create a smooth color gradiant to show a perfect map like this images ftp.goldensoftware/products/mapviewer/images_m6product/GradientMap.gif[^] www.georeference/doc/images/sc_surf_data_14.gif[^] please suggest me any sample code or any algorithms to make the value changes look smooth like this...., This will helpful to others they developing such applications.. I need like this i.imgur/GJAEp.png I am plotting only to that point and the remaining area will fill with appropritate color Thanks in advance...
推荐答案最初,您必须将可用的温度分布插值到整个输出图像. 您可以使用任何插值方法来创建插值. 根据新的温度(插值)值,您必须应用颜色图. 最后,您必须准备从黑色(0)->蓝色(49)->绿色(69)->黄色(68)->红色(107)开始的映射(每个温度RGB查找). 该贴图应具有从一种颜色到另一种颜色的平滑过渡.即,地图的索引59应该指示从蓝色到绿色的过渡. 以下库将有助于创建此类渐变. jmol.sourceforge/jscolors/ [ ^ ] 渐变图像: jmol.sourceforge/jscolors/gradients.png [ ^ ] 我不确定哪种方法是插值的好方法,可以使用双三次插值法或任何其他插值法通过较少的输入来创建整个图像的温度分布. en.wikipedia/wiki/Bicubic_interpolation [ ^ ] Initially, you have to interpolate the available temperature distribution to the entire output image. You can use any of the interpolation methods to create the interpolated values. Based on the new temperature(interpolated) values, you have to apply a color map. You have to prepare a map(RGB lookuptable for each temperature ) starting from black(0)->blue(49)->green(69)->yellow(68)->red(107) at last. This map should have a smooth transition from one color to other. ie, Index 59 of the map should indicate a transitaion from blue to green. The following library will be helpful to create such gradients. jmol.sourceforge/jscolors/[^] Gradient Image:jmol.sourceforge/jscolors/gradients.png[^] I''m not sure which is the good method for interpoaltion, Bi-Cubic interpolation or any other interpolation can be used to create the temperature distribution of the entire image from less number of inputs. en.wikipedia/wiki/Bicubic_interpolation[^]
我不知道任何现成的C ++代码,但是如果您只需要它的所谓的颜色渐变外观,则该算法非常简单,除非您还需要这些水平线,否则难度会更大.因此,您有一个包含两个坐标变量的函数,这些函数返回函数的值.首先,您需要找出所需范围内的最小值和最大值.由于这可能是一个问题,因此您可以在计算颜色图所需的所有点时找到这两个值,然后调整像素的颜色.另外,以RGB为地图定义最大"和最小"颜色.无论您的色彩空间是什么,在RGB中执行计算都更好. 现在,通过一些步骤将要显示的坐标空间的域分解为矩形网格.在最简单的情况下,该步骤将对应于像素的侧面.使用函数计算网格的所有点(到那时,您将知道最大值和最小值).假设您预定义了与最大值和最小值对应的像素的RGB颜色,请使用线性插值查找网格的所有其他点的像素颜色(这就是为什么我建议使用RGB的原因:RGB值的线性级数看起来是线性"的)肉眼可见;但是,您可以尝试其他颜色空间和非线性映射. 如果网格步长超过一个像素,则使图片由相同颜色的小方块(矩形)组成.在某种程度上,每个乡绅将代表一种大像素".映射到单个像素始终看起来会更好,但可能需要更多时间.如今,除非您使用非常慢的"GetPixel/SetPixel"之类的方法,否则它永远都不会太长.您应该始终使用指针或数组算术直接访问视频数据数组.这取决于您使用的图形库. 就这样. 顺便说一句,尝试改为创建3D视图.这不是很困难,但是会花费很多精力.使图片由用户自由旋转;只有这样才能提供真正的3D体验. 祝你好运,
更多推荐
使用代码的渐变图(算法)
发布评论