By Gavin Harriss

最近看到了这篇文章 很有意思     能不能用这个来实现 用户自定义的网站风格呢   有时间做个试验
Download source files - 8 Kb Download demo project - 27 Kb

Not coming from a graphics based background my method may not be the best solution, but it seems to work just fine.

To apply a color wash a base RGB color value is decided upon as a reference point and an adjustment value calculated for the color wash’s RGB value to be applied. This adjustment is calculated for each of the red, green and blue components. Once this is done each of the image’s pixel’s red, green and blue components is adjusted by the calculated amount to produce the color wash.

Each of the RGB components of a color can be represented by values from 0 to 255, so taking the mid point of 127 as the base reference point and taking the desired RGB component values of the color wash to apply we can calculate the adjustments to be made to each pixel.

Adjusting red, green and blue component values can sometimes result in a value outside the allowed range of 0 to 255; in these cases we compromise and simply use the minimum or maximum value allowed as appropriate.

The table below illustrates how values are adjusted:

  Hex Value Red Green Blue Color
 
Base Color 7F7F7F 127 127 127
Color Wash To Apply 1280AA 18 128 170
Adjustment Value To Use   18 – 127 = -109 128 – 127 = 1 170 – 127 = 43  
 
Example Pixel 1 Original Color A5A5A5 165 165 165
Example Pixel 1 Washed Color 38A6D0 165 – 109 = 56 165 + 1 = 166 165 + 43 = 208
 
Example Pixel 2 Original Color 545454 84 84 84
Example Pixel 2 Washed Color 00557F 84 – 109 = -25 = 0 * 84 + 1 = 85 84 + 43 = 127
 
Example Pixel 3 Original Color 2E2E2E 46 46 46
Example Pixel 3 Washed Color 002F59 46 – 109 = -63 = 0 * 46 + 1 = 47 46 + 43 = 89

* The value is less than the minimum allowed so we use the minimum instead.

Using the Code

To use this functionality in your projects simply download the source files accompanying this article, drop GavDev.Image.dll into the bin directory of your project then make a reference to the class library GavDev.Image.dll. There’s two interfaces provided for your convenience:

The first interface accepts individual red, green and blue values:

ColorWashImage(ByVal FilePathOriginal As String,ByVal FilePathNew As String,ByVal Red As Integer,ByVal Green As Integer,ByVal Blue As Integer,Optional ByVal Quality As Integer = 100,Optional ByVal Encoding As String = "image/jpeg")

The second interface allows you to pass a single combined 6 digit hexadecimal RGB value in as the color wash value:

ColorWashImage(ByVal FilePathOriginal As String,ByVal FilePathNew As String,ByVal HexRGBValue As String,Optional ByVal Quality As Integer = 100,Optional ByVal Encoding As String = "image/jpeg")

Both interfaces expect parameters FilePathOriginal, the physical location of the original grayscale image and FilePathNew, the physical location to save the resulting color washed image. Optional parameters are also present to dictate the quality and encoding of the output images.

Below is an example of the class being used as it is in the accompanying demo project:

GavDev.Image.Manipulate.ColorWashImage(Server.MapPath("Images/Gav.jpg"),Server.MapPath("Images/Gav." & txtColorWash.Text & ".jpg"),txtColorWash.Text)

转载于:https://www.cnblogs.com/stone/archive/2005/03/13/117908.html

Applying a Color Wash to Images相关推荐

  1. 室内空间摄影后期处理_摄影和录像中的后期制作或后期处理是什么?

    室内空间摄影后期处理 You've probably heard the terms "post-production," "post-processing," ...

  2. Jixipix Watercolor Studio Pro for Mac(照片转水彩画特效工具)

    Jixipix Watercolor Studio是一款专业且好用水彩画制作软件,用户只需要导入照片选择相应的滤镜就可以让你的照片拥有真实自然风格的水彩画效果,然后使用一系列滑块,图层,画笔,颜色洗涤 ...

  3. DeepFaceLab: 更新记录以及版本说明!

    DeepFaceLab更新记录以及版本说明 DeepFaceLab 从2018年开始,进入快速迭代更新,所以版本非常多.我们追随这个项目许久,保存了一些有价值的历史版本,并且对软件的更新做一个记录,方 ...

  4. Android APIs (Class Index - Android SDK)(二)

    类名 说明 R R.anim R.animator R.array R.attr R.bool R.color R.dimen R.drawable R.fraction R.id R.integer ...

  5. CVPR 2011 全部论文标题和摘要

    CVPR 2011 Tian, Yuandong; Narasimhan, Srinivasa G.; , ■Rectification and 3D reconstruction of curved ...

  6. 使用VTK引入基于物理的渲染

    原文地址:https://blog.kitware.com/vtk-pbr/ Introducing Physically Based Rendering with VTK Introduction ...

  7. GPU Gems 1: Chapter 22. Color Controls

    全屏后处理的颜色调整算法: 亮度:   float3 NewColor = OriginColor * fBrightness; 对比度:float3 NewColor = (OriginColor ...

  8. RGB Color Codes Chart

    RGB Color Codes Chart RGB颜色空间 RGB颜色空间或RGB颜色系统,从红色.绿色和蓝色的组合中构造所有颜色. 红色.绿色和蓝色各使用8位,它们的整数值从0到255.这使得256 ...

  9. 视频色彩校正简介 Introduction to Video Color Correction

    视频色彩校正简介 Introduction to Video Color Correction 视频色彩校正简介 Introduction to Video Color Correction MP4 ...

最新文章

  1. 设计模式原则之依赖倒置原则
  2. CentOS下首次使用as86汇编器
  3. 爬虫学习--豆瓣top250
  4. VMware ubuntu 上网2
  5. 如何编译文件(gcc + nasm)
  6. 【渝粤教育】国家开放大学2018年春季 0690-22T化工原理及实验 参考试题
  7. 微信小程序|开发实战篇之十-一些细节处理
  8. 微信团队回应“部分用户朋友圈无法刷新”;罗永浩:准备做综艺节目;Apache Spark 3.0 发布| 极客头条...
  9. 四、StackPanel控件
  10. 学习记录:xmind2testcase测试用例模板
  11. EXCEL自定义功能区Ribbon
  12. 初学者如何快速入门深度学习?
  13. 在 Pixel 3 手机上学习预测深度
  14. Facebook TSDB论文翻译
  15. (五)作业Job和实例Instance | 普罗米修斯(Prometheus)
  16. 计算机主机中包,百度地图脱机包最终可以在计算机上导入
  17. oracle 分区表,分区索引
  18. 绝地求生显示器测试软件,《绝地求生大逃杀》1728*1080分辨率怎么设置?自定义分辨率设置方法分享...
  19. XUPT-ACM校赛心得
  20. [FFmpeg] AVPacket 的使用记录(初始化、引用、解引用、释放)

热门文章

  1. python numpy 数组元素周围_Python numpy数组元素属性及访问
  2. 博达路由器如何配置互联网ip_如何成为技术大牛第七步——路由器下接交换机单臂路由配置方法...
  3. html文件整体结构,HTML文件基本结构
  4. 3-31Pytorch与auto-variabletensor
  5. Python机器学习:多项式回归与模型泛化008模型泛化与岭回归
  6. java动态删除map元素报错_java map使用迭代器遍历时执行删除元素报空指针异常
  7. mysql_install_db创建空库_MySQL数据库的初始化mysql_install_db
  8. java类怎么删除对象_java中对象的生成使用和删除
  9. python调用系统命令_Python调用外部系统命令
  10. oracle mysql增量迁移_从自建Oracle迁移至RDS MySQL