gpt4 book ai didi

python - 如何创建 "bluescale"图像

转载 作者:行者123 更新时间:2023-12-01 23:01:33 24 4
gpt4 key购买 nike

如何使用opencv制作类似本站的图片处理效果:

https://manytools.org/image/colorize-filter/

原创 enter image description here

已处理 enter image description here

我试着保留蓝色 channel ,或者给它填充灰度图像,红色和绿色 channel 都减少到0,但它们没有帮助,任何帮助都不胜感激。

最佳答案

@Suphanut had the right idea但没有充实它。我使用您的示例图像创建了自定义颜色图。结果并不完美,但非常接近。差异在轮舱边缘最为明显。我怀疑您的引用软件和 cv2 将图像转换为灰度的方式有所不同。

enter image description here

import cv2
img = cv2.imread(r'car.jpg', cv2.IMREAD_GRAYSCALE)
lut = np.array([
[[0,0,0]], [[0,0,0]], [[0,0,0]], [[0,0,0]],
[[0,0,0]], [[0,0,0]], [[0,0,0]], [[0,0,0]],
[[0,0,0]], [[0,0,0]], [[0,0,0]], [[0,0,0]],
[[0,0,0]], [[0,0,0]], [[0,0,0]], [[0,0,0]],
[[0,0,0]], [[0,0,0]], [[0,0,0]], [[0,0,0]],
[[0,0,0]], [[1,0,0]], [[1,0,0]], [[2,0,0]],
[[2,0,0]], [[3,0,0]], [[7,0,0]], [[13,0,0]],
[[19,0,0]], [[23,0,0]], [[24,0,0]], [[24,0,0]],
[[25,0,0]], [[27,0,0]], [[27,0,0]], [[28,0,0]],
[[30,0,0]], [[32,0,0]], [[33,0,0]], [[33,0,0]],
[[34,0,0]], [[36,0,0]], [[39,0,0]], [[40,0,0]],
[[41,0,0]], [[45,0,0]], [[48,0,0]], [[48,0,0]],
[[49,0,0]], [[53,0,0]], [[56,0,0]], [[58,0,0]],
[[64,0,0]], [[67,0,0]], [[69,0,0]], [[71,0,0]],
[[75,0,0]], [[78,0,0]], [[80,0,0]], [[82,0,0]],
[[85,0,0]], [[88,0,0]], [[89,0,0]], [[91,0,0]],
[[94,0,0]], [[96,0,0]], [[99,0,0]], [[103,0,0]],
[[106,0,0]], [[107,0,0]], [[110,0,0]], [[111,0,0]],
[[113,0,0]], [[113,0,0]], [[117,0,0]], [[117,0,0]],
[[121,0,0]], [[124,0,0]], [[129,0,0]], [[132,0,0]],
[[136,0,0]], [[138,0,0]], [[138,0,0]], [[139,0,0]],
[[141,0,0]], [[144,0,0]], [[144,0,0]], [[144,0,0]],
[[145,0,0]], [[149,0,0]], [[149,0,0]], [[151,0,0]],
[[154,0,0]], [[155,0,0]], [[157,0,0]], [[159,0,0]],
[[161,0,0]], [[164,0,0]], [[165,0,0]], [[167,0,0]],
[[169,0,0]], [[172,0,0]], [[174,0,0]], [[175,0,0]],
[[178,0,0]], [[181,0,0]], [[184,0,0]], [[186,0,0]],
[[189,0,0]], [[191,0,0]], [[195,0,0]], [[198,0,0]],
[[201,0,0]], [[203,0,0]], [[206,0,0]], [[209,0,0]],
[[212,0,0]], [[216,0,0]], [[218,0,0]], [[222,0,0]],
[[224,0,0]], [[227,1,1]], [[230,1,1]], [[233,1,1]],
[[236,1,1]], [[239,2,2]], [[241,2,2]], [[243,3,3]],
[[246,4,4]], [[248,5,5]], [[250,6,6]], [[252,7,7]],
[[253,9,9]], [[254,12,12]], [[255,15,15]], [[255,18,18]],
[[255,21,21]], [[255,25,25]], [[255,29,29]], [[255,31,31]],
[[255,36,36]], [[255,38,38]], [[255,42,42]], [[255,46,46]],
[[255,50,50]], [[255,53,53]], [[255,57,57]], [[255,60,60]],
[[255,62,62]], [[255,65,65]], [[255,68,68]], [[255,71,71]],
[[255,74,74]], [[255,76,76]], [[255,80,80]], [[255,82,82]],
[[255,86,86]], [[255,88,88]], [[255,91,91]], [[255,93,93]],
[[255,97,97]], [[255,99,99]], [[255,102,102]], [[255,105,105]],
[[255,108,108]], [[255,112,112]], [[255,117,117]], [[255,118,118]],
[[255,121,121]], [[255,122,122]], [[255,125,125]], [[255,126,126]],
[[255,129,129]], [[255,131,131]], [[255,133,133]], [[255,135,135]],
[[255,139,139]], [[255,144,144]], [[255,147,147]], [[255,152,152]],
[[255,154,154]], [[255,157,157]], [[255,162,162]], [[255,164,164]],
[[255,168,168]], [[255,170,170]], [[255,174,174]], [[255,177,177]],
[[255,180,180]], [[255,185,185]], [[255,188,188]], [[255,191,191]],
[[255,193,193]], [[255,196,196]], [[255,198,198]], [[255,200,200]],
[[255,202,202]], [[255,204,204]], [[255,206,206]], [[255,209,209]],
[[255,212,212]], [[255,214,214]], [[255,216,216]], [[255,218,218]],
[[255,221,221]], [[255,223,223]], [[255,225,225]], [[255,227,227]],
[[255,228,228]], [[255,230,230]], [[255,231,231]], [[255,234,234]],
[[255,235,235]], [[255,238,238]], [[255,238,238]], [[255,241,241]],
[[255,242,242]], [[255,244,244]], [[255,247,247]], [[255,249,249]],
[[255,250,250]], [[255,253,253]], [[255,253,253]], [[255,254,254]],
[[255,254,254]], [[255,253,253]], [[255,252,252]], [[255,253,253]],
[[255,254,254]], [[255,254,254]], [[255,254,254]], [[255,255,255]],
[[255,255,255]], [[255,255,255]], [[255,255,255]], [[255,255,255]],
[[255,255,255]], [[255,255,255]], [[255,255,255]], [[255,255,255]],
[[255,255,255]], [[255,255,255]], [[255,255,255]], [[255,255,255]],
[[255,255,255]], [[255,255,255]], [[255,255,255]], [[255,255,255]],
[[255,255,255]], [[255,255,255]], [[255,255,255]], [[255,255,255]],
[[255,255,255]], [[255,255,255]], [[255,255,255]], [[255,255,255]]],
dtype=np.uint8)
cv2.imshow('cv2', cv2.applyColorMap(img, lut))

显然,我对转换查找表进行了硬编码,但通过更多的分析,可能可以创建一个可以简单地生成它的公式。

关于python - 如何创建 "bluescale"图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71721493/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com