Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

滤镜算法 #14

Open
Chersquwn opened this issue Jun 22, 2020 · 1 comment
Open

滤镜算法 #14

Chersquwn opened this issue Jun 22, 2020 · 1 comment

Comments

@Chersquwn
Copy link
Owner

Chersquwn commented Jun 22, 2020

颜色减淡

结果色 = 基色 + (混合色 * 基色) / (255 - 混合色)

正片叠底

结果色 = 混合色 × 基色 / 255

颜色加深

结果色 = (基色 + 混合色 - 255) * 255 / 混合色

线性加深

结果色 = 基色 + 混合色 - 255

滤色

结果色 = 255 - 混合色的补色 * 基色的补色 / 255

叠加

基色 <= 128, 结果色 = 基色 × 混合色 / 128
基色 > 128, 结果色 = 255 - (255 - 基色)×(255 - 混合色)/ 128

灰度滤镜

R = 0.299 * R + 0.587 * G + 0.114 * B
G = 0.299 * R + 0.587 * G + 0.114 * B
B = 0.299 * R + 0.587 * G + 0.114 * B

连环画滤镜

R = | G - B + G + R | * R / 256
G = | B - G + B + R | * R / 256
B = | B - G + B + R | * G / 256

熔铸滤镜

R = R * 128 / (G + B + 1)
G = G * 128 / (R + B + 1)
B = B * 128 / (G + R + 1)

怀旧滤镜

R = R * 0.393 + G * 0.769 + B * 0.189
G = R * 0.349 + G * 0.686 + B * 0.168
B = R * 0.272 + G * 0.534 + B * 0.131

黑白滤镜

avg = (R + G + B) / 3
R = G = B = avg >= 100 ? 255 : 0

锐化滤镜(usm)

R' = 高斯模糊(R)
R = (R - k * R') / (1 - k), k = [0, 1]
G' = 高斯模糊(G)
G = (G - k * G') / (1 - k), k = [0, 1]
B' = 高斯模糊(B)
B = (B - k * B') / (1 - k), k = [0, 1]

对比度滤镜

avg = (R + G + B) / 3, 图像平均亮度,一般取128
R = (R - avg) * k + R
G = (G - avg) * k + G
B = (B - avg) * k + B

雾化滤镜

将当前像素位置打乱,换成随机位置像素。
dx = x + Math.random() * v
dy = y + Math.random() * v
P(x, y) = P(dx, dy)
@dyk326909207
Copy link

有程序吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants