python + openCV图像处理(一)

引言

此系列博客记录 网易云课堂 python + openCV图像处理课程的学习过程。

本篇博客将介绍 读取、显示、保存图像读取、修改 像素值(openCV 与 numpy) 三个部分。

介绍

OpenCV (Open Source Computer Vision Library) is released under a BSD license and hence it’s free for both academic and commercial use. It has C++, Python and Java interfaces and supports Windows, Linux, Mac OS, iOS and Android.

OpenCV was designed for computational efficiency and with a strong focus on real-time applications. Written in optimized C/C++, the library can take advantage of multi-core processing.

Enabled with OpenCL(一个为异构平台编写程序的框架), it can take advantage of the hardware acceleration of the underlying heterogeneous compute platform.

图像基础

1、图像都是由像素构成的,在同等面积下,像素点越多,图像越细腻。

2、图像分类:

  • 二值图像:图像只有 黑、白 两种颜色(像素点 0 或 1
  • 灰度图像:图像只有 黑、白、灰 三种颜色(像素点 0 - 255,其中 0 为黑色,255 为白色,1-254 之间均为灰色)
  • RGB图像彩色图像

tips: 二值和灰度图像 均为 单通道,RGB图像 为 三通道
在这里插入图片描述
3、彩色图像(RGB):由 红、绿、蓝 三色 按照某种比例混合而成的。

  • 比如:(255,182,193)表示浅粉红色,更常用的16进制 - #FFB6C1
    在这里插入图片描述

4、彩色图像(BGR):openCV库 专用,顺序为 蓝、绿、红 。
在这里插入图片描述

代码

1、读取、显示、保存图像

# -*- coding: utf-8 -*- 

import cv2 # 导入 openCV 库

i = cv2.imread(r"C:\workspace\python\openCV\test.jpg") # 读取
cv2.imshow("Demo",i) # 显示
cv2.waitKey(0) # 窗口等待
cv2.destroyAllWindow
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值