计算机视觉 opencv_使用opencv计算机视觉和螺旋波测试检测帕金森

2024-01-06 20:50

本文主要是介绍计算机视觉 opencv_使用opencv计算机视觉和螺旋波测试检测帕金森,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

计算机视觉 opencv

Utilizing computer vision and machine learning to automatically detect and predict Parkinson’s disease based on geometric drawings (i.e., spirals and sign waves).

利用计算机视觉和机器学习,可以根据几何图形(即螺旋形和符号波)自动检测和预测帕金森氏病。

绘制螺旋和波浪以检测帕金森氏病 (Drawing spirals and waves to detect Parkinson’s disease)

Image for post

A 2017 study by Zham et al. found that it was possible to detect Parkinson’s by asking the patient to draw a spiral and then track:

Zham等人的2017年研究。 发现可以通过要求患者画出螺旋线然后进行跟踪来检测帕金森氏症:

  1. Speed of drawing

    绘图速度
  2. Pen pressure

    笔压

The researchers found that the drawing speed was slower and the pen pressure lower among Parkinson’s patients — this was especially pronounced for patients with a more acute/advanced forms of the disease.

研究人员发现,帕金森氏症患者的绘画速度较慢,笔压较低-对于这种疾病的急性/晚期患者尤其如此

We’ll be leveraging the fact that two of the most common Parkinson’s symptoms include tremors and muscle rigidity which directly impact the visual appearance of a hand drawn spiral and wave.

我们将利用以下事实:帕金森氏症最常见的两种症状包括震颤和肌肉僵硬,这直接影响到手绘螺旋和波浪形的视觉外观。

The variation in visual appearance will enable us to train a computer vision and machine learning algorithm to automatically detect Parkinson’s disease.

视觉外观的变化将使我们能够训练计算机视觉和机器学习算法,以自动检测帕金森氏病。

数据集 (Dataset)

The dataset itself consists of 204 images and is pre-split into a training set and a testing set, consisting of:

数据集本身包含204张图像,并被预先划分为训练集和测试集,其中包括:

  • Spiral: 102 images, 72 training, and 30 testing

    螺旋: 102张图像,72次训练和30次测试

  • Wave: 102 images, 72 training, and 30 testing

    Wave: 102张图像,72次训练和30次测试

Here we would be applying two methods :

在这里,我们将应用两种方法:

  • Apply computer vision and OpenCV to detect Parkinson’s based on geometric drawings and then train a machine learning model to classify them

    应用计算机视觉和OpenCV检测基于几何图形的帕金森氏病,然后训练机器学习模型对其进行分类
  • Apply deep learning(Fastai)

    应用深度学习(法泰)

需要包装 (Packages Required)

  • OpenCV

    OpenCV
  • NumPy

    NumPy
  • Scikit-learn

    Scikit学习
  • Scikit-image

    Scikit图片
  • imutils

    不实用

导入库(Import Libraries)

Image for post

定义函数以HOG(定向直方图)方法量化波/螺旋图像(Define a function to quantify a wave/spiral image with the HOG(Histogram of Oriented Gradients) method)

Image for post

定义一个函数以接受数据集路径并返回所有要素数据和关联的类标签(Define a function to accept a dataset path and returning all feature data and associated class labels)

Image for post

提取训练和测试特征以获取螺旋图像(Extract Train and Test Features for spiral images)

Image for post
Image for post
Image for post
Image for post

将标签编码为整数(Encode the Labels into Integer)

Image for post

使用RandomForest分类器训练模型并评估测试图像(Train the model using RandomForest Classifier and evaluate on the test images)

Image for post
Image for post

遍历为每个线索生成的指标(Loop over the metrics generated for each trail)

Image for post

Output :

输出:

Image for post

Validation Accuracy for Spiral images is 82%

螺旋图像的验证精度为82%

测试在随机图像上训练的模型: (Test the model trained on random Images:)

  • randomly sample images from our testing set.

    从我们的测试集中随机采样图像。
  • Loop over the random image indices

    循环遍历随机图像索引
  • Image list will hold each wave or spiral image along with annotations added via OpenCV drawing functions.

    图像列表将保存每个波形或螺旋图像,以及通过OpenCV绘图功能添加的注释。
  • for each image in the list automatically classify the image using our new HOG + Random Forest based classifier and add color-coded annotations

    对于列表中的每个图像,使用我们新的基于HOG + Random Forest的分类器对图像进行自动分类,并添加颜色编码的注释

  • Finally add the image list to opencv montage for visualization

    最后将图像列表添加到opencv montage以进行可视化
Image for post
Image for post
Image for post

The opencv build_montages function requires three arguments:

opencv build_montages函数需要三个参数:

  • image_list : This parameter is a list of images loaded via OpenCV.

    image_list此参数是通过OpenCV加载的图像的列表。

  • image_shape: A tuple containing the width and height of each image in the montage.

    image_shape一个元组,包含蒙太奇中每个图像的宽度和高度。

  • montage_shape: A second tuple, this one specifying the number of columns and rows in the montage. Here we indicate that our montage will have 5columns (5 images wide) and 5rows (5 images tall).

    montage_shape第二个元组,该元组指定蒙太奇中的列和行数。 在这里,我们指示蒙太奇将有5列(宽5幅图像)和5行(高5幅图像)。

The build_montages method returns a list of montage images in NumPy array format.

build_montages方法以NumPy数组格式返回蒙太奇图像的列表。

Note: Empty space in the montage will be filled with black pixels.

注意:蒙太奇中的空白将被黑色像素填充。

Image for post

The class label is colored green for “healthy” and red for “parkinsons”

班级标签的绿色表示“健康” ,红色表示“帕金森”

类似地训练波形图像模型并在测试图像上进行评估 (Similarly training the model for wave images and evaluating on the test Images)

Output :

输出:

Image for post

Validation Accuracy for wave images is 65%

波浪图像的验证精度为65%

Image for post

帕金森病分类器:使用Fastai (Parkinsons Disease Classifier : using Fastai)

导入所需的Fastai库 (Import required Fastai libraries)

Image for post

设置图像路径(Set image path)

Image for post

启用变换(图像增强)(Enabling Transforms (Image Augmentation))

Transforms are passed on when creating the “ImageDataBunch” objects.Genearlly, you may enable the “Default” transforms by calling

创建“ ImageDataBunch”对象时会传递转换。通常,您可以通过调用启用“默认”转换

tfms = get_transforms()

tfms = get_transforms()

Image for post

The tuple contating transforms has 2 lists nested.

元组连续转换有两个嵌套的列表。

  • One is for the training dataset.

    一种是用于训练数据集。
  • Second one is for the validation dataset that involves minimal transforms/just resizing.

    第二个是用于验证数据集,该数据集涉及最少的转换/仅调整大小。

tfms [0] (tfms[0])

[RandTransform(tfm=TfmCrop (crop_pad), kwargs={‘row_pct’: (0, 1), ‘col_pct’: (0, 1), ‘padding_mode’: ‘reflection’}, p=1.0, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmAffine (dihedral_affine), kwargs={}, p=1.0, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmCoord (symmetric_warp), kwargs={‘magnitude’: (-0.2, 0.2)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmAffine (rotate), kwargs={‘degrees’: (-180, 180)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmAffine (zoom), kwargs={‘scale’: (1.0, 1.1), ‘row_pct’: (0, 1), ‘col_pct’: (0, 1)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmLighting (brightness), kwargs={‘change’: (0.4, 0.6)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmLighting (contrast), kwargs={‘scale’: (0.8, 1.25)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True)]

[RandTransform(tfm = TfmCrop (crop_pad),kwargs = {'row_pct':(0,1),'col_pct':(0,1),'padding_mode':'reflection'},p = 1.0,已解决= {} ,do_run = True,is_random = True,use_on_y = True),RandTransform(tfm = TfmAffine ( dihedral_affine) ,kwargs = {},p = 1.0,resolve = {},do_run = True,is_random = True,use_on_y = True), RandTransform(tfm = TfmCoord (symmetric_warp),kwargs = {'magnitude':(- 0.2,0.2 )},p = 0.75,resolve = {},do_run = True,is_random = True,use_on_y = True),RandTransform(tfm = TfmAffine (旋转),kwargs = {'度数:(-180,180)},p = 0.75,已解析= {},do_run = True,is_random = True,use_on_y = True),RandTransform(tfm = TfmAffine(zoom ), kwargs = {'scale':(1.0,1.1),'row_pct':(0,1),'col_pct':(0,1)},p = 0.75,resolve = {},do_run = True,is_random = True ,use_on_y = True),RandTransform(tfm = TfmLighting(亮度) ,kwargs = {'change':( 0.4,0.6 )},p = 0.75,resolve = {},do_run = True,is_random = True,use_on_y = True) ,RandTransform(tfm = TfmLighting(contrast) ,kwargs = {'scale':( 0.8,1.25 )},p = 0.75,resolve = {},do_run = True,is_random = True,use_on_y = True)]]

tfms [1] (tfms[1])

[RandTransform(tfm=TfmCrop (crop_pad), kwargs={}, p=1.0, resolved={}, do_run=True, is_random=True, use_on_y=True)]

[RandTransform(tfm = TfmCrop(crop_pad) ,kwargs = {},p = 1.0,已解决= {},do_run = True,is_random = True,use_on_y = True)]

使用fastai的ImageDataBunch类加载和准备数据 (Loading and preparing the data with fastai’s ImageDataBunch class)

Image for post

类标签:(Class Labels:)

data.classes :Class Labels for the training samples : [‘healthy’, ‘parkinson’]

data.classes训练样本的类别标签:['healthy','parkinson']

可视化数据 (Visualize the Data)

Image for post
Image for post
Image for post
Image for post

训练模型(Train the Model)

Image for post
Image for post
Image for post

找到最佳学习率(Find the Optimum learning rate)

Image for post
Image for post

应用最佳学习率(Applying optimum learning rate)

Image for post

情节损失(Plot Losses)

Image for post

混淆度量以评估模型性能(Confusion Metrics to evaluate the model performance)

Image for post
Image for post

保存第一个训练后的模型并找到训练和验证的准确性(Save the first trained model and find the training and validation accuracy)

Image for post

Here we could see that we could easily get a validation accuracy 0f 86% for Spiral images with only few lines of code as compared to the opencv+ ML code.

在这里我们可以看到,与opencv + ML代码相比,只需几行代码,就可以轻松获得螺旋图像的验证精度0f 86%。

可视化最大损失 (Visualize top losses)

Image for post
Image for post
Image for post
Image for post

虚拟化螺旋图像的预测(Viualize Predictions for Spiral images)

Image for post
Image for post
Image for post
Image for post

波浪图像的训练模型(Train Model for Wave Images)

Image for post
Image for post

显示结果(Show Results)

Image for post
Image for post
Image for post
Image for post

确定最佳学习率(Optimum Learning rate determined)

Image for post

应用最佳学习率(Applying Optimum Learning Rate)

Image for post
Image for post

评估训练波模型的性能(Evaluate the performance of trained wave model)

Image for post

训练和验证准确性(Training and Validation Accuracies)

Image for post

显示经过训练的模型的结果(Show Results for the trained Model)

Image for post
Image for post
Image for post

This validation accuracy is 83% for wave images with only few lines of code as compared to the opencv+ ML code.

与opencv + ML代码相比,仅几行代码的波形图像的验证精度为83%。

connect

连接

Reference:

参考:

Adrian Rosebrock的开放式简历和深度学习 (Open CV and Deep Learning by Adrian Rosebrock)

翻译自: https://medium.com/swlh/detecting-parkinsons-with-opencv-computer-vision-and-the-spiral-wave-test-e8de3b30f5e6

计算机视觉 opencv


http://www.taodudu.cc/news/show-8414625.html

相关文章:

  • 小脑萎缩和帕金森有什么区别
  • HPC在精神分裂症和帕金森症的个性化非侵入性临床治疗中的应用
  • 英特尔与迈克尔·J·福克斯基金会携手 用先进技术促进帕金森氏症治疗
  • 教你如何用python来爬取电影天堂上面的电影
  • Python爬虫框架:scrapy爬取迅雷电影天堂最新电影ed2k
  • Python爬虫框架:scrapy爬取迅雷电影天堂最新电影!
  • Safari 登录淘宝 提示:您的浏览器限制了第三方Cookie,这将影响您正常登录,您可以更改浏览器的隐私
  • 常见浏览器的User-Agent大全
  • 计算机网络单位换算问题汇总
  • 计算机网络单位换算题,单位换算练习题有那些?
  • 一道非常简单的单位换算题目
  • MAC--SR
  • NR - Scheduling Request
  • (学习opencv二刷) 形态学算法处理
  • 通信标准12之随机接入过程
  • 【泡泡学通信】SR:SCheduling request
  • LTE学习笔记--MAC--SR
  • LTE资源调度 -- 上行调度请求(2)SR
  • LTE资源调度(5)-上行调度请求SR
  • 【ps】新手 学 PS一本通 【书】
  • Go第七篇之规范的接口
  • 支付宝老版本的支付文档
  • 支付宝沙箱支付(java电脑版)
  • 支付宝电脑版二维码Java
  • 应急响应学习
  • 转:APK Crack
  • 解决卡巴斯基6.0自动断开连接重新启动
  • #创新应用#飞速流量压缩仪:移动互联网提速利器!
  • 无源互调分析仪——互调干扰案例分析
  • 自动化仪表
  • 这篇关于计算机视觉 opencv_使用opencv计算机视觉和螺旋波测试检测帕金森的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



    http://www.chinasem.cn/article/577576

    相关文章

    Spring IoC 容器的使用详解(最新整理)

    《SpringIoC容器的使用详解(最新整理)》文章介绍了Spring框架中的应用分层思想与IoC容器原理,通过分层解耦业务逻辑、数据访问等模块,IoC容器利用@Component注解管理Bean... 目录1. 应用分层2. IoC 的介绍3. IoC 容器的使用3.1. bean 的存储3.2. 方法注

    Python内置函数之classmethod函数使用详解

    《Python内置函数之classmethod函数使用详解》:本文主要介绍Python内置函数之classmethod函数使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 类方法定义与基本语法2. 类方法 vs 实例方法 vs 静态方法3. 核心特性与用法(1编程客

    Linux中压缩、网络传输与系统监控工具的使用完整指南

    《Linux中压缩、网络传输与系统监控工具的使用完整指南》在Linux系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

    使用Python实现可恢复式多线程下载器

    《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互

    Python中注释使用方法举例详解

    《Python中注释使用方法举例详解》在Python编程语言中注释是必不可少的一部分,它有助于提高代码的可读性和维护性,:本文主要介绍Python中注释使用方法的相关资料,需要的朋友可以参考下... 目录一、前言二、什么是注释?示例:三、单行注释语法:以 China编程# 开头,后面的内容为注释内容示例:示例:四

    Go语言数据库编程GORM 的基本使用详解

    《Go语言数据库编程GORM的基本使用详解》GORM是Go语言流行的ORM框架,封装database/sql,支持自动迁移、关联、事务等,提供CRUD、条件查询、钩子函数、日志等功能,简化数据库操作... 目录一、安装与初始化1. 安装 GORM 及数据库驱动2. 建立数据库连接二、定义模型结构体三、自动迁

    ModelMapper基本使用和常见场景示例详解

    《ModelMapper基本使用和常见场景示例详解》ModelMapper是Java对象映射库,支持自动映射、自定义规则、集合转换及高级配置(如匹配策略、转换器),可集成SpringBoot,减少样板... 目录1. 添加依赖2. 基本用法示例:简单对象映射3. 自定义映射规则4. 集合映射5. 高级配置匹

    Spring 框架之Springfox使用详解

    《Spring框架之Springfox使用详解》Springfox是Spring框架的API文档工具,集成Swagger规范,自动生成文档并支持多语言/版本,模块化设计便于扩展,但存在版本兼容性、性... 目录核心功能工作原理模块化设计使用示例注意事项优缺点优点缺点总结适用场景建议总结Springfox 是

    嵌入式数据库SQLite 3配置使用讲解

    《嵌入式数据库SQLite3配置使用讲解》本文强调嵌入式项目中SQLite3数据库的重要性,因其零配置、轻量级、跨平台及事务处理特性,可保障数据溯源与责任明确,详细讲解安装配置、基础语法及SQLit... 目录0、惨痛教训1、SQLite3环境配置(1)、下载安装SQLite库(2)、解压下载的文件(3)、

    使用Python绘制3D堆叠条形图全解析

    《使用Python绘制3D堆叠条形图全解析》在数据可视化的工具箱里,3D图表总能带来眼前一亮的效果,本文就来和大家聊聊如何使用Python实现绘制3D堆叠条形图,感兴趣的小伙伴可以了解下... 目录为什么选择 3D 堆叠条形图代码实现:从数据到 3D 世界的搭建核心代码逐行解析细节优化应用场景:3D 堆叠图