基本小函数(11)
发布时间:2021-06-06
发布时间:2021-06-06
图像处理的有用资料
R = ColVal(2, X, Y) G = ColVal(1, X, Y) B = ColVal(0, X, Y)
Gray = R * 3 + G * 6 + B Gray = Gray \ 10
.ColorCount(Gray) = .ColorCount(Gray) + 1 Next Next
.PixcelCount = X * Y '获得图片的像素总量 C = 1 / .PixcelCount
.ColRatio( 0) = .ColorCount(M, 0) * C '计算每个亮度的出现比例 .NewVal(0) = 0 '色值最小的色彩总是为0,不参与计算 L = 0
For I = 1 To 255
.ColRatio(I) = .ColorCount(I) * C + .ColRatio(L) '进行加权
.NewVal(I) = .ColRatio(I) * 255 '计算新的颜色索引 L = L + 1 Next
For X = 0 To OutPutWid For Y = 0 To OutPutHei
R = Colval(2, X, Y) '读取原来点的颜色 G = Colval(1, X, Y) B = Colval(0, X, Y)
R = .NewVal(R) '查表得到新的颜色 G = .NewVal(G) B = .NewVal(B)
ColOut(2, X, Y) = R '把新的颜色放到输出数组中 ColOut(1, X, Y) = G ColOut(0, X, Y) = B Next Next End With
Done = True
TimeFilter = timeGetTime - TimeFilter Exit Sub ErrLine:
Done = True
MsgBox Err.Description End Sub