C#图像亮度调式与伪彩 * 的处理教程(推荐)
作者:Yulong5759 时间:2022-03-26 19:43:54
如图,左图是效果,右图是原理,右图X轴代表图像一个像素点的灰度,Y轴代表RGB三个颜色对应的伪彩 * 颜色。代码如下:
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Color c = bmp.GetPixel(x, y);
int R = c.R; int G = c.G; int B = c.B;
byte temp = (byte)(B * 0.114 + G * 0.587 + R * 0.299);
if (temp >= 0 && temp <= 63)
{
bmp.SetPixel(x, y, Color.FromArgb(0, (byte)(4 * temp), (byte)255));
}
if (temp >= 64 && temp <= 127)
{
bmp.SetPixel(x, y, Color.FromArgb(0, 255, (byte)(510 - 4 * temp)));
}
if (temp >= 128 && temp <= 191)
{
bmp.SetPixel(x, y, Color.FromArgb((byte)(4 * temp - 510), 255, 0));
}
if (temp >= 192 && temp <= 255)
{
bmp.SetPixel(x,y, Color.FromArgb(255, (byte)(1022 - 4 * temp),0));
}
}
}
图像亮度调整:
for (int y = 50; y < 100; y++)
{
for (int x = 50; x < 100; x++)
{
// 处理指定位置像素的亮度
Color c = b.GetPixel(x, y);
int R = c.R; int G = c.G; int B = c.B;
R = R + degree; if (R > 255) R = 255;
G = G + degree; if (G > 255) G = 255;
B = B + degree; if (B > 255) B = 255;
b.SetPixel(x, y, Color.FromArgb(R, G, B));
}
}//其中degree是亮度阶梯度
来源:http://www.cnblogs.com/liyulongBlog/archive/2017/11/27/7904562.html
标签:C#,图像,亮度调式,伪彩 , ,处理
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
MyBatis注解实现动态SQL问题
2023-08-19 02:34:09
浅谈C#多线程简单例子讲解
2023-06-24 03:03:50
详解Spring Boot自动装配的方法步骤
2023-11-18 15:02:18
springboot集成spring cache缓存示例代码
2021-10-20 07:57:54
SpringBoot使用SensitiveWord实现敏感词过滤
2023-09-06 19:35:21
springboot集成与使用Sentinel的方法
2023-08-31 11:22:30
![](https://img.aspxhome.com/file/2023/2/74762_0s.png)
Javaweb开发环境Myeclipse6.5 JDK1.6 Tomcat6.0 SVN1.8配置教程
2023-11-15 21:47:05
![](https://img.aspxhome.com/file/2023/1/73091_0s.png)
java比较器Comparable接口与Comaprator接口的深入分析
2022-01-20 11:51:09
详解Java进阶知识注解
2023-08-12 13:11:37
![](https://img.aspxhome.com/file/2023/5/65775_0s.png)
JNDI简介_动力节点Java学院整理
2023-04-20 03:19:23
Unity实现3D循环滚动效果
2023-04-22 14:05:47
![](https://img.aspxhome.com/file/2023/4/68624_0s.png)
Unity实现滑动更换界面效果
2021-10-06 19:56:40
![](https://img.aspxhome.com/file/2023/6/84466_0s.jpg)
Netty序列化深入理解与使用
2023-05-24 20:13:07
![](https://img.aspxhome.com/file/2023/8/60758_0s.png)
浅谈Servlet开发技术基础
2023-01-17 04:03:15
深入解析Java并发程序中线程的同步与线程锁的使用
2022-03-19 10:25:38
![](https://img.aspxhome.com/file/2023/1/65621_0s.jpg)
C#中foreach原理以及模拟的实现
2022-04-07 23:18:12
Java读取并下载网络文件的方法
2023-03-18 11:47:05
完美解决java读取大文件内存溢出的问题
2023-07-31 17:53:17
使用C# CefSharp Python采集某网站简历并且自动发送邀请短信的方法
2023-11-17 14:09:34
![](https://img.aspxhome.com/file/2023/6/102196_0s.png)
通过java反射机制动态调用某方法的总结(推荐)
2022-11-04 01:38:32