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

做网站本溪新站整站快速排名

做网站本溪,新站整站快速排名,星巴克网站开发票,深圳企业网站制作公司查询文章目录 1、CIELAB 色彩空间2、作色问题定义3、Caffe 模型4、代码实现——Image5、代码实现——Video6、参考 1、CIELAB 色彩空间 Lab颜色空间,也称为Lab色彩空间或CIELAB色彩空间,是一种基于人类视觉感知特性的颜色模型。它是在1931年国际照明委员会&…

在这里插入图片描述

文章目录

  • 1、CIELAB 色彩空间
  • 2、作色问题定义
  • 3、Caffe 模型
  • 4、代码实现——Image
  • 5、代码实现——Video
  • 6、参考

1、CIELAB 色彩空间

Lab颜色空间,也称为Lab色彩空间或CIELAB色彩空间,是一种基于人类视觉感知特性的颜色模型。它是在1931年国际照明委员会(CIE)制定的颜色度量国际标准的基础上建立的,并在1976年经过修订和完善。Lab颜色空间以其独特的优点在多个领域得到广泛应用。

Lab颜色空间是一种颜色-对立空间,它包含三个维度:L、a和b。

  • L:表示亮度(Luminosity),取值范围为0到100,对应从纯黑到纯白的亮度变化。

  • a:表示颜色对立维度之一,通常与绿色到红色的范围相对应,取值范围为-128到+127,其中负值表示绿色方向,正值表示洋红方向。

  • b:表示另一个颜色对立维度,通常与蓝色到黄色的范围相对应,取值范围同样为-128到+127,其中负值表示蓝色方向,正值表示黄色方向。

2、作色问题定义

参考文章

Zhang R, Isola P, Efros A A. Colorful image colorization[C]//Computer Vision–ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Proceedings, Part III 14. Springer International Publishing, 2016: 649-666.

在这里插入图片描述

在这里插入图片描述

为了简化计算,Lab 颜色空间的 ab 空间被量化为 313 个 bin,如下图所示。而不是为每个像素找到 a 和 b 值,因为这种量化,我们只需要找到一个介于 0 和 312之间的 bin 编号。另一种思考问题的方式是我们已经有了取值从 0 到 255 的 L 通道,我们需要找到取值在 0 到 312 之间的 ab 通道。所以颜色预测任务现在是变成了多分类问题,其中每个灰色像素有 313 个类别可供选择

在这里插入图片描述

3、Caffe 模型

在这里插入图片描述

colorization_release_v1

在这里插入图片描述

colorization_release_v2
在这里插入图片描述
colorization_release_v2_norebal
在这里插入图片描述

4、代码实现——Image

# This code is written by Sunita Nayak at BigVision LLC. It is based on the OpenCV project.
# It is subject to the license terms in the LICENSE file found in this distribution and at http://opencv.org/license.html#### Usage example: python3 colorize.py --input greyscaleImage.pngimport numpy as np
import cv2 as cv
import argparse
import os.pathparser = argparse.ArgumentParser(description='Colorize GreyScale Image')
parser.add_argument('--input', help='Path to image.', default="greyscaleImage.png")
args = parser.parse_args()if args.input==None:print('Please give the input greyscale image name.')print('Usage example: python3 colorizeImage.py --input greyscaleImage.png')exit()if os.path.isfile(args.input)==0:print('Input file does not exist')exit()# Read the input image
frame = cv.imread(args.input)# Specify the paths for the 2 model files
protoFile = "./models/colorization_deploy_v2.prototxt"
weightsFile = "./models/colorization_release_v2.caffemodel"
# weightsFile = "./models/colorization_release_v2_norebal.caffemodel"# Load the cluster centers
pts_in_hull = np.load('./pts_in_hull.npy')# Read the network into Memory
net = cv.dnn.readNetFromCaffe(protoFile, weightsFile)# populate cluster centers as 1x1 convolution kernel
pts_in_hull = pts_in_hull.transpose().reshape(2, 313, 1, 1)
net.getLayer(net.getLayerId('class8_ab')).blobs = [pts_in_hull.astype(np.float32)]
net.getLayer(net.getLayerId('conv8_313_rh')).blobs = [np.full([1, 313], 2.606, np.float32)]#from opencv sample
W_in = 224
H_in = 224img_rgb = (frame[:,:,[2, 1, 0]] * 1.0 / 255).astype(np.float32)
img_lab = cv.cvtColor(img_rgb, cv.COLOR_RGB2Lab)
img_l = img_lab[:,:,0] # pull out L channel# resize lightness channel to network input size
img_l_rs = cv.resize(img_l, (W_in, H_in)) #
img_l_rs -= 50 # subtract 50 for mean-centeringnet.setInput(cv.dnn.blobFromImage(img_l_rs))
ab_dec = net.forward()[0,:,:,:].transpose((1,2,0)) # this is our result(H_orig,W_orig) = img_rgb.shape[:2] # original image size
ab_dec_us = cv.resize(ab_dec, (W_orig, H_orig))
img_lab_out = np.concatenate((img_l[:,:,np.newaxis],ab_dec_us),axis=2) # concatenate with original image L
img_bgr_out = np.clip(cv.cvtColor(img_lab_out, cv.COLOR_Lab2BGR), 0, 1)outputFile = args.input[:-4]+'_colorized.png'
cv.imwrite(outputFile, (img_bgr_out*255).astype(np.uint8))
print('Colorized image saved as '+outputFile)
print('Done !!!')

cluster center

// 来自 pts_in_hull.npy 的 313 个 ab 聚类中心(已经转置)
static float hull_pts[] = {-90., -90., -90., -90., -90., -80., -80., -80., -80., -80., -80., -80., -80., -70., -70., -70., -70., -70., -70., -70., -70.,-70., -70., -60., -60., -60., -60., -60., -60., -60., -60., -60., -60., -60., -60., -50., -50., -50., -50., -50., -50., -50., -50.,-50., -50., -50., -50., -50., -50., -40., -40., -40., -40., -40., -40., -40., -40., -40., -40., -40., -40., -40., -40., -40., -30.,-30., -30., -30., -30., -30., -30., -30., -30., -30., -30., -30., -30., -30., -30., -30., -20., -20., -20., -20., -20., -20., -20.,-20., -20., -20., -20., -20., -20., -20., -20., -20., -10., -10., -10., -10., -10., -10., -10., -10., -10., -10., -10., -10., -10.,-10., -10., -10., -10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 10., 10., 10., 10., 10., 10., 10.,10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20.,20., 20., 20., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 30., 40., 40., 40., 40.,40., 40., 40., 40., 40., 40., 40., 40., 40., 40., 40., 40., 40., 40., 40., 40., 50., 50., 50., 50., 50., 50., 50., 50., 50., 50.,50., 50., 50., 50., 50., 50., 50., 50., 50., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60., 60.,60., 60., 60., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 70., 80., 80., 80.,80., 80., 80., 80., 80., 80., 80., 80., 80., 80., 80., 80., 80., 80., 80., 80., 90., 90., 90., 90., 90., 90., 90., 90., 90., 90.,90., 90., 90., 90., 90., 90., 90., 90., 90., 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 50., 60., 70., 80., 90.,20., 30., 40., 50., 60., 70., 80., 90., 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., -20., -10., 0., 10., 20., 30., 40., 50.,60., 70., 80., 90., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., -40., -30., -20., -10., 0., 10., 20.,30., 40., 50., 60., 70., 80., 90., 100., -50., -40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., -50.,-40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., -60., -50., -40., -30., -20., -10., 0., 10., 20.,30., 40., 50., 60., 70., 80., 90., 100., -70., -60., -50., -40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., 90.,100., -80., -70., -60., -50., -40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., -80., -70., -60., -50.,-40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., 90., -90., -80., -70., -60., -50., -40., -30., -20., -10.,0., 10., 20., 30., 40., 50., 60., 70., 80., 90., -100., -90., -80., -70., -60., -50., -40., -30., -20., -10., 0., 10., 20., 30.,40., 50., 60., 70., 80., 90., -100., -90., -80., -70., -60., -50., -40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70.,80., -110., -100., -90., -80., -70., -60., -50., -40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., -110., -100.,-90., -80., -70., -60., -50., -40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., 80., -110., -100., -90., -80., -70.,-60., -50., -40., -30., -20., -10., 0., 10., 20., 30., 40., 50., 60., 70., -110., -100., -90., -80., -70., -60., -50., -40., -30.,-20., -10., 0., 10., 20., 30., 40., 50., 60., 70., -90., -80., -70., -60., -50., -40., -30., -20., -10., 0.
};

Class rebalancing

输入图片

在这里插入图片描述

v2 without re-balance
在这里插入图片描述
v2 with re-balance
在这里插入图片描述

输入图片

在这里插入图片描述

v2 without re-balance

在这里插入图片描述

v2 with re-balance

在这里插入图片描述

输入图片

在这里插入图片描述

v2 without re-balance

在这里插入图片描述

v2 with re-balance

在这里插入图片描述
输入图片

在这里插入图片描述

v2 without re-balance

在这里插入图片描述

v2 with re-balance

在这里插入图片描述

输入图片

在这里插入图片描述

v2 without re-balance

在这里插入图片描述

v2 with re-balance

在这里插入图片描述

输入图片

在这里插入图片描述

v2 without re-balance

在这里插入图片描述

v2 with re-balance

在这里插入图片描述

输入图片

在这里插入图片描述

v2 without re-balance

在这里插入图片描述

v2 with re-balance

在这里插入图片描述

可以观察到引入 color rebalance 后,整体画面变得更黄

5、代码实现——Video

# This code is written by Sunita Nayak at BigVision LLC. It is based on the OpenCV project.
# It is subject to the license terms in the LICENSE file found in this distribution and at http://opencv.org/license.html#### Usage example: python3 colorizeVideo.py --input greyscaleVideo.mp4import numpy as np
import cv2 as cv
import argparse
import os.pathparser = argparse.ArgumentParser(description='Colorize GreyScale Video')
parser.add_argument('--input', help='Path to video file.')
args = parser.parse_args()if args.input==None:print('Please give the input greyscale video file.')print('Usage example: python3 colorizeVideo.py --input greyscaleVideo.mp4')exit()if os.path.isfile(args.input)==0:print('Input file does not exist')exit()# Read the input video
cap = cv.VideoCapture(args.input)
hasFrame, frame = cap.read()outputFile = args.input[:-4]+'_colorized.avi'
vid_writer = cv.VideoWriter(outputFile, cv.VideoWriter_fourcc('M','J','P','G'), 60, (frame.shape[1],frame.shape[0]))# Specify the paths for the 2 model files
protoFile = "./models/colorization_deploy_v2.prototxt"
# weightsFile = "./models/colorization_release_v2.caffemodel"
weightsFile = "./models/colorization_release_v2_norebal.caffemodel"# Load the cluster centers
pts_in_hull = np.load('./pts_in_hull.npy')# Read the network into Memory
net = cv.dnn.readNetFromCaffe(protoFile, weightsFile)# populate cluster centers as 1x1 convolution kernel
pts_in_hull = pts_in_hull.transpose().reshape(2, 313, 1, 1)
net.getLayer(net.getLayerId('class8_ab')).blobs = [pts_in_hull.astype(np.float32)]
net.getLayer(net.getLayerId('conv8_313_rh')).blobs = [np.full([1, 313], 2.606, np.float32)]#from opencv sample
W_in = 224
H_in = 224while cv.waitKey(1):hasFrame, frame = cap.read()frameCopy = np.copy(frame)if not hasFrame:breakimg_rgb = (frame[:,:,[2, 1, 0]] * 1.0 / 255).astype(np.float32)img_lab = cv.cvtColor(img_rgb, cv.COLOR_RGB2Lab)img_l = img_lab[:,:,0] # pull out L channel# resize lightness channel to network input sizeimg_l_rs = cv.resize(img_l, (W_in, H_in))img_l_rs -= 50 # subtract 50 for mean-centeringnet.setInput(cv.dnn.blobFromImage(img_l_rs))ab_dec = net.forward()[0,:,:,:].transpose((1,2,0)) # this is our result(H_orig,W_orig) = img_rgb.shape[:2] # original image sizeab_dec_us = cv.resize(ab_dec, (W_orig, H_orig))img_lab_out = np.concatenate((img_l[:,:,np.newaxis],ab_dec_us),axis=2) # concatenate with original L channelimg_bgr_out = np.clip(cv.cvtColor(img_lab_out, cv.COLOR_Lab2BGR), 0, 1)vid_writer.write((img_bgr_out*255).astype(np.uint8))vid_writer.release()print('Colorized video saved as '+outputFile)
print('Done !!!')

输入视频

greyscaleVideo

结果

colorization_release_v2_noreba

Result-colorization_release_v2

可以观察到引入 color rebalance 后,整体画面变得更黄

6、参考

  • OpenCV进阶(9)基于OpenCV的图像着色

  • 图像着色领域可有什么经典论文?

http://www.dinnco.com/news/40444.html

相关文章:

  • 德州汇泽网站建设青岛自动seo
  • 学院网站建设推进会国外搜索引擎有哪些
  • 房产中介网站模板适合成人参加的培训班
  • 免费生产管理erp网店搜索引擎优化的方法
  • phpweb网站开发参考文献信阳网站推广公司
  • 中国建设银行官网站企业百度seo公司报价
  • 开个网站做代理赚钱吗开发一个平台需要多少钱
  • 城阳建网站深圳网络推广哪家公司好
  • 电子科技 深圳 网站建设今日重大事件
  • 网站兼容ie代码seo是一种利用搜索引擎
  • 网站 公司实力网址查询服务器地址
  • 汪峰做的音乐网站重庆网页优化seo
  • 装修网站怎么做的好处个人博客网站怎么做
  • python网站开发集成环境宁波seo网站推广软件
  • 火山开发软件可以开发网站吗张掖seo
  • 网络公司网站模板在线seo短视频
  • 织梦怎么做淘客网站怎么在线上推广自己的产品
  • 上海设计招聘网站新的网络推广方式
  • 重庆网站设计公司排行网址seo关键词
  • 学校网站建设实训北京网站优化方法
  • .net网站开发岗位免费做网站怎么做网站链接
  • 虚拟app制作网站seo关键词设置
  • 在哪个网站做跨境电商seo优化厂商
  • 网站建设会面临些什么问题四川省人民政府官网
  • 怎么做视频解析的网站搜百度盘
  • 建网站为什么要租空间无锡优化网站排名
  • 深圳做棋牌网站建设哪家好推广seo公司
  • wordpress update_post_metaseo的名词解释
  • 搭建邮箱注册网站网络营销seo是什么意思
  • 禅城网站建设报价长沙seo霜天博客