图像处理与分析
图像处理算法学习
xiongyuqing
看见我请叫我学英语
展开
-
边缘检测
import cv2 as cv import numpy as np img = cv.imread('1.png') #Sobel算子边缘检测 sobel = cv.Sobel(img, cv.CV_16S, 1, 0, ksize=3) #Laplacian边缘检测 laplacian = cv.Laplacian(img, cv.CV_16S) #Canny边缘检测,最小阈值50, 最大阈值120 canny = cv.Canny(img, 50, 120) sobel_show = cv.原创 2020-06-08 09:39:08 · 288 阅读 · 0 评论 -
图像分割
import cv2 as cv import numpy as np import copy import matplotlib.pyplot as plt """ image, contours, hierarchy = cv.findContours(image, mode, method[, contoursr[,hierarchy[,offset]]]) image: 单通道图像矩阵,可以是灰度值,但是更常用的是经过边缘检测算子处理后的二值图像 contours:定义为’vector<v.原创 2020-06-08 09:33:01 · 203 阅读 · 0 评论 -
图像变换
import cv2 as cv import matplotlib.pyplot as plt import numpy as np img = cv.imread('1.png') # 读入图像 cv.imshow('Source', img) # 显示图像 # 图像改变大小和翻转 w, h = img.shape[0:2] # 取图像的长和宽 resized = cv.resize(img, (int(w/4), int(h/2))) # 重新设定图像大小 flipped = .原创 2020-05-29 01:19:02 · 247 阅读 · 0 评论 -
图像平滑滤波
import cv2 as cv import numpy as np def gauss_noise(image, mean = 0, var = 0.001): """ 添加高斯噪声 :param image: 图像 :param mean: 均值 :param var: 方差 :return: 添加噪声后的图像 """ image = np.array(image/255, dtype = float) noise = np..原创 2020-05-26 21:11:54 · 606 阅读 · 0 评论 -
图像采样与量化
图像采样与量化 MATLAB程序: I = imread('hw1.jpg'); % 读入图像 I1 = rgb2gray(I); % 将RGB图像转换为灰度图像 % 采样: I2 = I1(1:2:end, 1:2:end); % 图像缩小1/4 I3 = I1(1:4:end, 1:4:end); % 图像缩小1/8 I4 = I1(1:8:end, 1:8:end); % 图像缩小1/16 I5 = I1(1:16:end, 1:16:end); % 图像缩小1/32 figure; subplot原创 2020-09-13 14:36:58 · 724 阅读 · 0 评论