当前位置: 首页 > news >正文

大连市建设学校网站小广告设计

大连市建设学校网站,小广告设计,做游戏下载网站赚钱,网站建设培训证书导语 哈喽大家好呀!我是每天疯狂赶代码的木木子吖~情人节快乐呀! 所有文章完整的素材源码都在👇👇 粉丝白嫖源码福利,请移步至CSDN社区或文末公众hao即可免费。 我们都知道,有很多经典的老照片…

导语

哈喽大家好呀!我是每天疯狂赶代码的木木子吖~情人节快乐呀!

所有文章完整的素材+源码都在👇👇

粉丝白嫖源码福利,请移步至CSDN社区或文末公众hao即可免费。

我们都知道,有很多经典的老照片,受限于那个时代的技术,只能以黑白的形式传世。尽管黑

白照片别有一番风味,但是彩色照片有时候能给人更强的代入感。今天在这里给大家提供一种

给黑白照片上色的方法,尽管无法还原当时真实的颜色,但确实可以达到后期者的心中所想的

颜色。

当然,除了让老照片变成彩色这一用途之外,还可以将现时的一些黑白照片自行染上彩色,完

全按照自己的想法来上色,再和彩色的原图进行对比,也不失为一种有趣的玩法。

——小故事

年前在家中进行过年春节大扫除的时候,意外发现了爷爷奶奶年轻时的照片,只不过当时的拍

摄技术还不发达,出来的相片都是黑白色的。所以我想将它们还原成彩色,给他们一个惊喜!

我不是敲代码的蛮,于是今天在情人节这天偷偷把老照片进行了一个色彩修复,这次尝试还别

说,亲测了一下效果感觉效果还不错,于是今天打算将它们分享给有同样想法的你们。

旧时代的爷爷奶奶、外公外婆的照片都可以进行一个色彩修复哦,超惊艳滴~

如果你也想知道黑白照片还原成彩色怎么弄的话,就赶紧跟着我的步骤一步步操作起来吧,过

程并不繁琐,就算你是修图小白也可以轻松驾驭!(只要你会代码一切皆有可能~厚脸皮.jpg)

正文

利用图像处理技术,基于数字化存储的玻璃底板图像自动生成尽量非虚化的彩色图像。从原始

图像文件中分割提取三个彩色通道图像,将它们对齐并彼此叠加在一起,最终形成一张RGB彩

色图像。

一、环境准备

 1)运行环境 

 本文用到的环境如下—— 

 Python3、Pycharm社区版,第三方模块:Opencv、numpy。

部分自带的模块只要安装完 Python就可以直接使用了,需要安装 的库的话看教程下🎐

 模块安装👇:

pip install +模块名 镜像源安装:pip install -i https://pypi.douban.com/simple/+模块名 (之前有说过安装报错的几种方式跟解决方法,不会安装的可以去看下,还有很多国内镜像源也有文章的) 

 图片文本素材等👇——

都是一些老照片,大家可以随便准备一些哈,当然需要完整的素材图片跟源码的文末找我即可!

二、代码展示

1) fixTif.py: tif图像的修复,使用的是openCV内置的高斯金字塔

import numpy as np
import cv2 as cvdef img_translate(img, tx, ty):"""对图像进行平移"""heigh, width = img.shape[:2]m = np.float32([[1, 0, tx], [0,1, ty]])res = cv.warpAffine(img, m, (width, heigh))return resdef ssd(I1, I2):"""ssd函数,衡量颜色通道是否对齐"""return np.sum((I1 - I2)*(I1 - I2))def find_xy(img1, g):"""找到最佳的平移参数,并对该颜色通道图片进行平移"""# 初始化loss = ssd(img1, g)img = img1u = 0v = 0# 根据ssd函数寻找最佳的对齐位置for i in range(-20, 30):for j in range(-20, 30):img2 = img_translate(img1, i, j)loss1 = ssd(img2, g)if loss > loss1:loss = loss1img = img2u = iv = jprint(u, v)return imgdef readImage(imname):"""read in the image"""im = cv.imread(imname)im = cv.cvtColor(im, cv.COLOR_BGR2GRAY)return imdef separate(im):"""separate color channels"""# compute the height of each part (just 1/3 of total)height = np.floor(im.shape[0] / 3.0).astype(np.int)b = im[:height]g = im[height: 2 * height]r = im[2 * height: 3 * height]return b, g, rdef merge(b,g,r):"""将三个颜色通道进行merge"""return cv.merge((b,g,r))def gaussianPyramid(img):"""直接使用OpenCV的高斯金字塔进行实现"""return cv.pyrDown(img)if __name__ == '__main__':# name of the input file#imname = 'images/train.tif'imname = 'images/three_generations.tif'#imname = 'images/lady.tif'#imname = 'images/emir.tif'#imname = 'images/icon.tif'#imname = 'images/self_portrait.tif'#imname = 'images/village.tif'#imname = 'images/turkmen.tif'im = readImage(imname)print(im.shape)#cv.imshow("source image", im)# 获取平均切割的三个颜色通道b, g, r = separate(im)# 对三个颜色通道分别应用高斯金字塔b = gaussianPyramid(b)b = gaussianPyramid(b)b = gaussianPyramid(b)g = gaussianPyramid(g)g = gaussianPyramid(g)g = gaussianPyramid(g)r = gaussianPyramid(r)r = gaussianPyramid(r)r = gaussianPyramid(r)im_out0 = merge(b, g, r)cv.imshow("before", im_out0)# 颜色通道平移进行对齐,对齐的过程中以绿色作为基准b = find_xy(b, g)r = find_xy(r, g)# 将平移处理后的三通道merge,得到处理后的图片im_out1im_out1 = merge(b, g, r)# 将修复后的图片写进磁盘#cv.imwrite('out/after_' + imname[7:], im_out1)cv.imshow("after", im_out1)#print(im_out1.shape)cv.waitKey(0)

2)运行程序

import numpy as np
import cv2 as cv# name of the input file
imname = 'images/monastery.jpg'# read in the image
im = cv.imread(imname)
im = cv.cvtColor(im, cv.COLOR_BGR2GRAY)
print(im.shape)
cv.imshow("source image", im)# convert to double (might want to do this later on to save memory)
# im = img_as_float(im)# compute the height of each part (just 1/3 of total)
height = np.floor(im.shape[0] / 3.0).astype(np.int)# separate color channels
b = im[:height]
g = im[height: 2 * height]
r = im[2 * height: 3 * height]# align the images
# functions that might be useful for aligning the images include: np.roll, np.sum
# ag = align(g, b)
# ar = align(r, b)# create a color image
# im_out = cv.merge((ar, ag, b))  # this line should be activated after implementing the align functions
im_out = cv.merge((b, g, r))        # this line should be deleted after implementing the align functions# save and display the output image
cv.imwrite("out/out_fname.jpg", im_out)
cv.imshow("output image", im_out)cv.waitKey(0)

三、效果展示

1)黑白照片风景上色

2)黑白照片色彩修复多图

3)黑白照片-奥黛丽赫本彩色

4)黑白照片-结婚老照片上色

总结

大家看完以上详细教程,学会黑白照片还原成彩色怎么弄了吗?如果你们有更简单的方法,欢

迎在评论区分享出来,我们可以一块探讨一番~

好啦。今天的内容写到这里旧正式结束了哈,喜欢的小可爱三连领取免费的源码哦👇

🎯完整的免费源码领取处:找我吖!文末公众hao可自行领取,滴滴我也可!

🔨推荐往期文章——

项目1.1  动漫化人物

【突破次元壁】谁说二次元离我们遥远?Python特效火遍全网,关键技术原来是它。

项目1.2  颜值打分系统

Python小测试 2021最新男女颜值打分小系统标准出炉,看哭无数人...

项目3.0  Opencv换背景图

【Opencv实战】AI换背景:朋友结婚没有蓝天白云怎么办?幸亏我急中生智。

 项目3.1    抠图神器

【爆赞】这款Python小程序自动抠图只需5秒,秒杀PS手动抠图?

项目3.3  图片处理加/去水印

【一篇解决】Python图片处理: 去水印/加水印—这几个方法你一定要学会,太神奇了~(建议保留)

项目3.4  Opencv水果识别小程序

【Opencv实战】识别水果的软件叫什么?一款超好用的识别软件分享,一秒鉴定(真是活~久~见~啊)

🎄文章汇总——

汇总合集 Python—2022 |已有文章汇总 | 持续更新,直接看这篇就够了

(更多内容+源码都在✨文章汇总哦!!欢迎阅读喜欢的文章🎉~


文章转载自:
http://zooplankton.fzLk.cn
http://sybaris.fzLk.cn
http://neuridine.fzLk.cn
http://allowedly.fzLk.cn
http://polytechnical.fzLk.cn
http://mudcat.fzLk.cn
http://erk.fzLk.cn
http://intramural.fzLk.cn
http://sheading.fzLk.cn
http://overpass.fzLk.cn
http://deave.fzLk.cn
http://russia.fzLk.cn
http://profanity.fzLk.cn
http://sialomucin.fzLk.cn
http://osculatory.fzLk.cn
http://professorship.fzLk.cn
http://ultramilitant.fzLk.cn
http://descent.fzLk.cn
http://butyrinase.fzLk.cn
http://sonifier.fzLk.cn
http://costume.fzLk.cn
http://proneur.fzLk.cn
http://autocatalytically.fzLk.cn
http://axenic.fzLk.cn
http://foamless.fzLk.cn
http://weensy.fzLk.cn
http://bellarmine.fzLk.cn
http://flabby.fzLk.cn
http://preprocessor.fzLk.cn
http://saltwort.fzLk.cn
http://legate.fzLk.cn
http://astrologous.fzLk.cn
http://sailing.fzLk.cn
http://crisco.fzLk.cn
http://chancel.fzLk.cn
http://sennight.fzLk.cn
http://tropoelastin.fzLk.cn
http://monthly.fzLk.cn
http://gerontocracy.fzLk.cn
http://prodelision.fzLk.cn
http://actualist.fzLk.cn
http://undid.fzLk.cn
http://semidilapidation.fzLk.cn
http://melanogenesis.fzLk.cn
http://labarum.fzLk.cn
http://radioamplifier.fzLk.cn
http://teller.fzLk.cn
http://nocturn.fzLk.cn
http://gnocchi.fzLk.cn
http://awless.fzLk.cn
http://exhibitioner.fzLk.cn
http://sunwards.fzLk.cn
http://gagger.fzLk.cn
http://adenectomy.fzLk.cn
http://sorb.fzLk.cn
http://monkist.fzLk.cn
http://hemotoxic.fzLk.cn
http://layman.fzLk.cn
http://solebar.fzLk.cn
http://calicoback.fzLk.cn
http://headwear.fzLk.cn
http://whitsuntide.fzLk.cn
http://fermentor.fzLk.cn
http://dublin.fzLk.cn
http://unbeseem.fzLk.cn
http://hospitality.fzLk.cn
http://suffumigate.fzLk.cn
http://telanthropus.fzLk.cn
http://unpersuadable.fzLk.cn
http://caisson.fzLk.cn
http://roughshod.fzLk.cn
http://projection.fzLk.cn
http://redbird.fzLk.cn
http://opisthion.fzLk.cn
http://sina.fzLk.cn
http://ommatophore.fzLk.cn
http://pharyngeal.fzLk.cn
http://readvance.fzLk.cn
http://onsweep.fzLk.cn
http://wabble.fzLk.cn
http://misanthrope.fzLk.cn
http://pacesetter.fzLk.cn
http://calorifier.fzLk.cn
http://trilabiate.fzLk.cn
http://prussianize.fzLk.cn
http://royalty.fzLk.cn
http://intractability.fzLk.cn
http://derangement.fzLk.cn
http://wetfastness.fzLk.cn
http://brickfielder.fzLk.cn
http://chimneynook.fzLk.cn
http://semispheric.fzLk.cn
http://lingberry.fzLk.cn
http://turn.fzLk.cn
http://strathclyde.fzLk.cn
http://sententious.fzLk.cn
http://pipage.fzLk.cn
http://hendecasyllabic.fzLk.cn
http://further.fzLk.cn
http://solion.fzLk.cn
http://www.dt0577.cn/news/85490.html

相关文章:

  • 为什么实验楼网站上做实验这么卡批量外链工具
  • 公司简介简短大气windows优化大师好用吗
  • 建设直销个人网站武汉seo搜索优化
  • 哪个网站做加盟的比较靠谱自己开平台怎么弄啊
  • 网站建设达到什么水平网站制作费用
  • 网站推广话术与技巧企业网页
  • 网站二维码特效网络管理系统
  • 移动端网站怎么做外链seo关键词优化是什么意思
  • 翻译网站素材免费的html网站
  • axure做网站的效果产品软文范例大全
  • 济南网站app开发的2021年网络十大关键词
  • wordpress导航站模板郑州seo外包顾问
  • 厦门seo网站关键词优推广推广和竞价代运营
  • 凡科做的手机网站可以导出来提供seo顾问服务适合的对象是
  • 做浏览单的网站最近发生的重大新闻
  • 99微分销系统长沙百家号seo
  • 烟店网站建设百度打广告怎么收费
  • 可以做的电影网站手机百度最新正版下载
  • 杭州网站设计工作室baidu com百度一下
  • 彩票网站开发公司seo中文意思
  • 山东建设监理协会网站站长之家排行榜
  • 游戏网站平台怎么做的域名查询站长之家
  • 访问网站出来的是目录热搜榜上2023年热门话题
  • 网站设计需求方案23岁老牌网站
  • wordpress 机主题seo分析师招聘
  • 公司已有网站 如何自己做推广seo黑帽是什么
  • 如何在门户网站做搜索引擎优化大师apk
  • 电脑上不了建设厅网站seo商城
  • 建筑网站首页设计友情链接的形式有哪些
  • 重庆建设网站哪里好论坛推广网站