位置: IT常识 - 正文

模式识别与图像处理课程实验一:图像处理实验(颜色算子实验、Susan、Harris角点检测实验、 sobel边缘算子检测实验)(模式识别与图像处理能做什么)

发布时间:2024-01-17
模式识别与图像处理课程实验一:图像处理实验(颜色算子实验、Susan、Harris角点检测实验、 sobel边缘算子检测实验) 模式识别与图像处理课程实验一:图像处理实验-->> 颜色算子实验、Susan、Harris角点检测实验、 sobel边缘算子检测实验一、 实验内容二、 颜色算子实验2.1、 提取红色2.2、 提取绿色2.3、 提取蓝色三、 Susan、Harris角点检测实验3. 1、 实验程序3.1.1、Susan角点检测3.1.2、Harris角点检测四、 sobel边缘算子检测实验4.1、sobel边缘算子检五、 实验总结

推荐整理分享模式识别与图像处理课程实验一:图像处理实验(颜色算子实验、Susan、Harris角点检测实验、 sobel边缘算子检测实验)(模式识别与图像处理能做什么),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:模式识别与图像识别的区别,模式识别与图像处理车牌识别结课报告,模式识别与图像处理能做什么,模式识别与图像处理就业,模式识别与图像处理区别,模式识别与图像处理就业方向,模式识别与图像处理,模式识别与图像识别,内容如对您有帮助,希望把文章链接给更多的朋友!

一、 实验内容

要求编写一个包含颜色算子,Susan,Harris,角点,sobel边缘算子的程。

二、 颜色算子实验2.1、 提取红色实验的程序如下import numpy as npimport cv2 as cvimage = cv.imread("1.jpg")image = image / np.ones([1, 1, 3]).astype(np.float32)image = cv.cvtColor(image, cv.COLOR_BGR2RGB)print(image.shape)# 颜色算子# redredAdd = np.ones([1, 1, 3]).astype(np.float32)redAdd[0, 0, 0] = 1.0redAdd[0, 0, 1] = 0.5redAdd[0, 0, 2] = 0.25redSub = np.ones([1, 1, 3]).astype(np.float32)redSub[0, 0, 0] = 0.25redSub[0, 0, 1] = 0.5redSub[0, 0, 2] = 1.0image1 = np.mean(image * redAdd, 2)image2 = np.mean(image * redSub, 2) + 100imageRed = image1 / image2redMax = np.max(imageRed)redMin = np.min(imageRed)imageRed = 255 * (imageRed - redMin) / (redMax - redMin)cv.imwrite("1red.png", imageRed)

运行结果如下

实验原图 实验结果图 2.2、 提取绿色

实验的程序如下

import numpy as npimport cv2 as cvimage = cv.imread("1.jpg")image = image / np.ones([1, 1, 3]).astype(np.float32)image = cv.cvtColor(image, cv.COLOR_BGR2RGB)print(image.shape)# greengreenAdd = np.ones([1, 1, 3]).astype(np.float32)greenAdd[0, 0, 0] = 0.5greenAdd[0, 0, 1] = 1.0greenAdd[0, 0, 2] = 0.25greenSub = np.ones([1, 1, 3]).astype(np.float32)greenSub[0, 0, 0] = 0.5greenSub[0, 0, 1] = 0.25greenSub[0, 0, 2] = 1.0image1 = np.mean(image * greenAdd, 2)image2 = np.mean(image * greenSub, 2) + 100imageGreen = image1 / image2greenMax = np.max(imageGreen)greenMin = np.min(imageGreen)imageRed = 255 * (imageGreen - greenMin) / (greenMax - greenMin)cv.imwrite("1green.png", imageRed)

运行结果如下

实验原图

实验结果图

2.3、 提取蓝色实验的程序如下import numpy as npimport cv2 as cvimage = cv.imread("1.jpg")image = image / np.ones([1, 1, 3]).astype(np.float32)image = cv.cvtColor(image, cv.COLOR_BGR2RGB)print(image.shape)# bulebuleAdd = np.ones([1, 1, 3]).astype(np.float32)buleAdd[0, 0, 0] = 0.25buleAdd[0, 0, 1] = 0.5buleAdd[0, 0, 2] = 1.0buleSub = np.ones([1, 1, 3]).astype(np.float32)buleSub[0, 0, 0] = 1.0buleSub[0, 0, 1] = 0.5buleSub[0, 0, 2] = 0.25image1 = np.mean(image * buleAdd, 2)image2 = np.mean(image * buleSub, 2) + 100imageBlue = image1 / image2blueMax = np.max(imageBlue)blueMin = np.min(imageBlue)imageBlue = 255 * (imageBlue - blueMin) / (blueMax - blueMin)cv.imwrite("1blue.png", imageBlue)模式识别与图像处理课程实验一:图像处理实验(颜色算子实验、Susan、Harris角点检测实验、 sobel边缘算子检测实验)(模式识别与图像处理能做什么)

运行结果如下

实验原图

实验结果图

三、 Susan、Harris角点检测实验3. 1、 实验程序3.1.1、Susan角点检测

Susan角点检测程序如下

import numpy as npimport cv2 as cvimage = cv.imread("2.jpg")image = np.mean(image, 2)height = image.shape[0]width = image.shape[1]print(image.shape)#susan 算子radius = 5imageSusan = np.zeros([height, width]).astype(np.float32)for h in range(radius, height-radius): for w in range(radius, width-radius): numSmall = 0 numLarge = 0 numAll = 0 for y in range(-radius, radius + 1): for x in range(-radius, radius+1): distance = np.sqrt(y**2 + x**2) if distance <= radius: numAll += 1 if image[h + y, w + x] < image[h, w] - 27: numSmall += 1 if image[h + y, w + x] > image[h, w] + 27: numLarge += 1 ratio = 1.0 * numSmall / numAll ratio2 = 1.0 * numLarge / numAll if ratio < 0.3: imageSusan[h, w] = 0.3 - ratio if ratio2 > 0.7: imageSusan[h, w] = ratio2 - 0.7imageMax = np.max(imageSusan)imageMin = np.min(imageSusan)imageSusan = 255*(imageSusan - imageMin)/(imageMax - imageMin)print(imageSusan.shape)cv.imwrite("2.png", imageSusan)运行结果如下

实验原图

实验结果图

3.1.2、Harris角点检测Harris角点检测程序如下import cv2 as cvimport numpy as npimport matplotlib.pyplot as plt# 读取图像img = cv.imread('3.jpg')lenna_img = cv.cvtColor(img, cv.COLOR_BGR2RGB)# 图像转换成灰度图像grayImage = cv.cvtColor(img, cv.COLOR_BGR2GRAY)grayImage = np.float32(grayImage)# Harris算子harrisImage = cv.cornerHarris(grayImage, 2, 3, 0.04)harrisImage = cv.dilate(harrisImage, None)# 设置阈值thresImage = 0.006 * harrisImage.max()img[harrisImage > thresImage] = [255, 0, 0]# 显示正常中文的标签plt.rcParams['font.sans-serif'] = ['SimHei']titles = [u'(a)原始图像', u'(b)Harris图像']images = [lenna_img, img]for i in range(2): plt.subplot(1, 2, i + 1), plt.imshow(images[i], 'gray') plt.title(titles[i]) plt.xticks([]), plt.yticks([])plt.show()

运行结果如下

四、 sobel边缘算子检测实验4.1、sobel边缘算子检sobel边缘算子检程序如下import numpy as npimport cv2image = cv2.imread("3.jpg")height = image.shape[0]width = image.shape[1]sobelResult = np.zeros([height - 2, width - 2, 1]).astype(np.float32)sobelX = np.zeros([3, 3, 1]).astype(np.float32)sobelY = np.zeros([3, 3, 1]).astype(np.float32)sobelX[0, 0, 0] = -1sobelX[1, 0, 0] = -2sobelX[2, 0, 0] = -1sobelX[0, 2, 0] = 1sobelX[1, 2, 0] = 2sobelX[2, 2, 0] = 1sobelY[0, 0, 0] = -1sobelY[0, 1, 0] = -2sobelY[0, 2, 0] = -1sobelY[2, 0, 0] = 1sobelY[2, 1, 0] = 2sobelY[2, 2, 0] = 1for h in range(0, height - 3): for w in range(0, width - 3): #求方向梯度 imageIncre = image[h:h + 3, w:w + 3] gradientX = np.sum(imageIncre * sobelX) gradientY = np.sum(imageIncre * sobelY) gradient = np.sqrt(gradientX**2 + gradientY**2) sobelResult[h, w, 0] = gradientimageMax = np.max(sobelResult)imageMin = np.min(sobelResult)sobelResult = 255*(sobelResult - imageMin) / (imageMax - imageMin)cv2.imwrite("3.png", sobelResult)

2、 运行结果如下

实验原图

实验结果图

五、 实验总结1、 掌握了编写含颜色算子图像处理、Susan与Harris角点图像检测、sobel边缘算子图像检测的程序编写方法。2、 通过实验、对于边缘检测算子与角点检测算子有了进一步的掌握。
本文链接地址:https://www.jiuchutong.com/zhishi/298747.html 转载请保留说明!

上一篇:【网络应用开发】实验1--Servlet技术及应用(网络应用开发技术)

下一篇:【JavaScript】JS实用案例分享:选择器组件 | 简易计算器(javascript js)

  • 资金账簿印花税减半征收后可以叠加享受优惠吗
  • 缴纳个税会计分录是什么
  • 以前损益年度调整
  • 会计凭证包括哪三种
  • 取用备用金要188分
  • 报关金额多报了3000美金
  • 金税三期个人所得税税率
  • 索赔费用项目
  • 增值税即征即退2023政策
  • 银行承兑汇票利息怎么算
  • 企业对外借款是怎么规定的
  • 企业购买扶贫物资怎么入账
  • 没有进项的产品开了发票怎么办
  • 航天金税服务费怎么做账
  • 增值税发票税率是星号
  • 新公司营业执照经营范围越多越好吗
  • 定额发票2019
  • 公司与政府协议
  • 利润减库存为什么不等于现金
  • 职工福利费和教育费的计提比例
  • 分公司需要核准名称吗
  • 财务软件里凭证打印如何设置不打印三级科目
  • 公司旅游的费用怎么算
  • win10蓝牙驱动程序下载
  • 工资做账表格怎么做
  • 暂估人工成本分录怎么写
  • 农产品进项转出的规定
  • PHP:oci_new_connect()的用法_Oracle函数
  • linux的基础知识
  • 代扣代缴的增值税算进项税吗
  • 文件夹字体怎么变大
  • 股权转让协议合同
  • php与jquery
  • 缴住房公积金会计分录怎么写
  • pa等比例缩放
  • php限制接口调用次数
  • 新所得税会计准则
  • 劳务费怎么做会计分裤
  • 留抵税额是认证过的发票吗
  • fping命令参数
  • 保税进料加工企业
  • wordpress标签tag文章
  • 待抵扣进项税额和进项税额的区别
  • 外籍专家劳务费
  • 所有者权益变动表模板excel
  • mysql有什么优势和特点
  • 设计费可以抵扣进项吗
  • 购买监控器计入什么科目
  • 收到联营企业分红怎么做
  • 个人所得税专项扣除2023最新政策
  • 月末研发支出会结转至哪个账户
  • 什么企业的应急预案需要备案
  • 转让金融商品应交增值税可以抵扣吗
  • 进项税额已经抵扣会计分录
  • 销售返利如何做账
  • 财产租赁合同印花税计税依据
  • 小规模纳税人收到专票的会计分录
  • 小规模纳税人增值税计算公式
  • mysql 修改配置
  • win7安装sqlserver2005失败
  • win10预览版好吗
  • ubuntu发行版介绍
  • mac自带功能流程图
  • win7系统添加右键菜单在哪里设置
  • linux 翻译
  • Linux VPN 出现 807 错误的解决办法
  • cocos2d-x教程
  • Unity3D事件函数的执行顺序
  • android网络通信http
  • 性能优化实验
  • linux删除文件语句
  • python3 ftplib
  • shell脚本逐条执行
  • python入门教程
  • 经营所得个人所得税税率表
  • 注册财税公司需要什么条件
  • 灯具维修发票明细
  • 宁波市开发区
  • 电力企业所得税按期
  • 房地产契税2023年最新政策
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号