皱纹检测Wrinkle-detection

2023-05-16

基于图像处理的皱纹检测算法。

https://github.com/bulingda/Wrinkles_detection/blob/master/Wrinkle.py

 基于RCNN 毛孔检测

https://github.com/jack16888/Faster-RCNN-for-pore-detection

 

 from PIL import Image
 import cv2
 import time
 import numpy as np
 from skimage.filters import frangi, gabor
 from skimage import measure, morphology
 from Partition import practice14 as pa
 #
 # class UnionFindSet(object):
 #
 # def __init__(self, m):
 # # m, n = len(grid), len(grid[0])
 # self.roots = [i for i in range(m)]
 # self.rank = [0 for i in range(m)]
 # self.count = m
 #
 # for i in range(m):
 # self.roots[i] = i
 #
 # def find(self, member):
 # tmp = []
 # while member != self.roots[member]:
 # tmp.append(member)
 # member = self.roots[member]
 # for root in tmp:
 # self.roots[root] = member
 # return member
 #
 # def union(self, p, q):
 # parentP = self.find(p)
 # parentQ = self.find(q)
 # if parentP != parentQ:
 # if self.rank[parentP] > self.rank[parentQ]:
 # self.roots[parentQ] = parentP
 # elif self.rank[parentP] < self.rank[parentQ]:
 # self.roots[parentP] = parentQ
 # else:
 # self.roots[parentQ] = parentP
 # self.rank[parentP] -= 1
 # self.count -= 1
 #
 #
 # class Solution(object):
 # def countComponents(self, n, edges):
 # """
 # :type n: int
 # :type edges: List[List[int]]
 # :rtype: int
 # """
 # ufs = UnionFindSet(n)
 # # print ufs.roots
 # for edge in edges:
 # start, end = edge[0], edge[1]
 # ufs.union(start, end)
 #
 # return ufs.count
 #
 #
 # # def connected_component(thresh_A):
 # # thresh_A_copy = thresh_A.copy() # 复制thresh_A到thresh_A_copy
 # # thresh_B = np.zeros(thresh_A.shape).astype(int) # thresh_B大小与A相同,像素值为0
 # #
 # # kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (3, 3)) # 3×3结构元
 # #
 # # count = [] # 为了记录连通分量中的像素个数
 # # xy_count = []
 # # # 循环,直到thresh_A_copy中的像素值全部为0
 # # while thresh_A_copy.any():
 # # Xa_copy, Ya_copy = np.where(thresh_A_copy > 0) # thresh_A_copy中值为255的像素的坐标
 # # thresh_B[Xa_copy[0]][Ya_copy[0]] = 1 # 选取第一个点,并将thresh_B中对应像素值改为255
 # #
 # # # 连通分量算法,先对thresh_B进行膨胀,再和thresh_A执行and操作(取交集)
 # # for i in range(thresh_A.shape[0]):
 # # dilation_B = cv2.dilate(thresh_B, kernel, iterations=1)
 # # print(type(thresh_A), type(dilation_B.astype(int)))
 # # thresh_B = cv2.bitwise_and(np.uint8(thresh_A), dilation_B.astype(int))
 # #
 # # # 取thresh_B值为255的像素坐标,并将thresh_A_copy中对应坐标像素值变为0
 # # Xb, Yb = np.where(thresh_B > 0)
 # # thresh_A_copy[Xb, Yb] = 0
 # # xy_count.append(np.c_[Xb, Yb])
 # # # 显示连通分量及其包含像素数量
 # # count.append(len(Xb))
 # # if len(count) == 0:
 # # print("无连通分量")
 # # if len(count) == 1:
 # # print("第1个连通分量为{}".format(count[0]))
 # # print(xy_count[0], "2")
 # # ecc = measure.regionprops(xy_count[0])
 # # print(ecc[0].eccentricity)
 # # if len(count) >= 2:
 # # if (count[-1] - count[-2]) < 2:
 # # continue
 # # print("第{}个连通分量为{}".format(len(count), count[-1] - count[-2]))
 # # print(xy_count[len(count) - 1][len(xy_count[-2]):len(xy_count[-1])], "2")
 # # ecc = measure.regionprops(xy_count[len(count) - 1][len(xy_count[-2]):len(xy_count[-1])])
 # # print(ecc[0].eccentricity)
 # def connected_component(path):
 # img_A = cv2.imread(path)
 # gray_A = cv2.cvtColor(img_A, cv2.COLOR_BGR2GRAY) # 转换成灰度图
 # ret, thresh_A = cv2.threshold(gray_A, 20, 255, cv2.THRESH_BINARY_INV) # 灰度图转换成二值图像
 # print(thresh_A, "thresh_A")
 # thresh_A_copy = thresh_A.copy() # 复制thresh_A到thresh_A_copy
 # thresh_B = np.zeros(thresh_A.shape, np.uint8) # thresh_B大小与A相同,像素值为0
 #
 # kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3)) # 3×3结构元
 #
 # count = [] # 为了记录连通分量中的像素个数
 # xy_count = []
 # # 循环,直到thresh_A_copy中的像素值全部为0
 # while thresh_A_copy.any():
 # Xa_copy, Ya_copy = np.where(thresh_A_copy > 0) # thresh_A_copy中值为255的像素的坐标
 # thresh_B[Xa_copy[0]][Ya_copy[0]] = 255 # 选取第一个点,并将thresh_B中对应像素值改为255
 #
 # # 连通分量算法,先对thresh_B进行膨胀,再和thresh_A执行and操作(取交集)
 # for i in range(200):
 # dilation_B = cv2.dilate(thresh_B, kernel, iterations=1)
 # thresh_B = cv2.bitwise_and(thresh_A, dilation_B)
 #
 # # 取thresh_B值为255的像素坐标,并将thresh_A_copy中对应坐标像素值变为0
 # Xb, Yb = np.where(thresh_B > 0)
 # thresh_A_copy[Xb, Yb] = 0
 # xy_count.append(np.c_[Xb, Yb])
 # # 显示连通分量及其包含像素数量
 # count.append(len(Xb))
 # if len(count) == 0:
 # print("无连通分量")
 # if len(count) == 1:
 # print("第1个连通分量为{}".format(count[0]))
 # # print(np.c_[Xb, Yb], "1")
 # print(xy_count[0], "2")
 #
 # ecc = measure.regionprops(xy_count[0])
 # print(ecc[0].eccentricity)
 # if len(count) >= 2:
 # if (count[-1] - count[-2]) < 2:
 # continue
 # print("第{}个连通分量为{}".format(len(count), count[-1] - count[-2]))
 # # print(np.c_[Xb, Yb], "1")
 # print(xy_count[len(count) - 1][len(xy_count[-2]):len(xy_count[-1])], "2")
 # ecc = measure.regionprops(xy_count[len(count) - 1][len(xy_count[-2]):len(xy_count[-1])])
 # print(ecc[0].eccentricity)
  
  
 def master_control(image):
 # image = cv2.resize(image, (int(image.shape[1]*0.3), int(image.shape[0]*0.3)), interpolation=cv2.INTER_CUBIC) # 图片分辨率很大是要变小
 b, g, r = cv2.split(image) # image
  
 sk_frangi_img = frangi(g, scale_range=(0, 1), scale_step=0.01, beta1=1.5, beta2=0.01) # 线宽范围,步长,连接程度(越大连接越多),减少程度(越大减得越多)0.015
 sk_frangi_img = morphology.closing(sk_frangi_img, morphology.disk(1))
 sk_gabor_img_1, sk_gabor_1 = gabor(g, frequency=0.35, theta=0)
 sk_gabor_img_2, sk_gabor_2 = gabor(g, frequency=0.35, theta=45) # 越小越明显
 sk_gabor_img_3, sk_gabor_3 = gabor(g, frequency=0.35, theta=90)
 sk_gabor_img_4, sk_gabor_4 = gabor(g, frequency=0.35, theta=360) # 横向皱纹
 sk_gabor_img_1 = morphology.opening(sk_gabor_img_1, morphology.disk(2))
 sk_gabor_img_2 = morphology.opening(sk_gabor_img_2, morphology.disk(1))
 sk_gabor_img_3 = morphology.opening(sk_gabor_img_3, morphology.disk(2))
 sk_gabor_img_4 = morphology.opening(sk_gabor_img_4, morphology.disk(2))
 all_img = cv2.add(0.1 * sk_gabor_img_2, 0.9 * sk_frangi_img) # + 0.02 * sk_gabor_img_1 + 0.02 * sk_gabor_img_2 + 0.02 * sk_gabor_img_3
 all_img = morphology.closing(all_img, morphology.disk(1))
 _, all_img = cv2.threshold(all_img, 0.3, 1, 0)
 img1 = all_img
 # print(all_img, all_img.shape, type(all_img))
 # contours, image_cont = cv2.findContours(all_img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
 # all_img = all_img + image_cont
 bool_img = all_img.astype(bool)
 label_image = measure.label(bool_img)
 count = 0
  
 for region in measure.regionprops(label_image):
 if region.area < 10: # or region.area > 700
 x = region.coords
 for i in range(len(x)):
 all_img[x[i][0]][x[i][1]] = 0
 continue
 if region.eccentricity > 0.98:
 count += 1
 else:
 x = region.coords
 for i in range(len(x)):
 all_img[x[i][0]][x[i][1]] = 0
  
 skel, distance = morphology.medial_axis(all_img.astype(int), return_distance=True)
 skels = morphology.closing(skel, morphology.disk(1))
 trans1 = skels # 细化
 return skels, count # np.uint16(skels.astype(int))
  
  
 def face_wrinkle(path):
 # result = pa.curve(path, backage)
 result = cv2.imread(path)
 img, count = master_control(result)
 print(img.astype(float))
 result[img > 0.1] = 255
 cv2.imshow("result", img.astype(float))
 cv2.waitKey(0)
  
  
 if __name__ == '__main__':
 path = r"D:\E\document\datas\line\2885.png"
 backage = r'..\Sebum\shape_predictor_81_face_landmarks.dat'
  
 face_wrinkle(path)

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

皱纹检测Wrinkle-detection 的相关文章

  • ubuntu ifconfig命令无效解决方案

    1 更新或升级系统 sudo apt get update 2 安装ipconfig的工具 sudo apt install net tools 3 查看ip ifconfig
  • 树莓派4b镜像烧录以及如何无显示屏远程登陆操作

    1 树莓派的烧录 xff1a 树莓派的烧录我用了很长的时间 xff0c 重新烧录的很多次 xff0c 都是因为没办法打开ssh xff0c 所以没办法进入树莓派调试 因为我使用树莓派主要是用来部署yolov5进行识别物体的 xff0c 所以
  • MyBatis入门——动态SQL

    前言 在我们日常工作中 xff0c 使用MyBatis除了做一般的数据查询之外 xff0c 还有很多业务场景下需要我们针对不同条件从数据库中获取到满足指定条件的数据 xff0c 这时候我们应该如何来做呢 xff1f 针对每种条件封装一个方法
  • Docker搭建本地私有仓库

    和Mavan的管理一样 xff0c Dockers不仅提供了一个中央仓库 xff0c 同时也允许我们使用registry搭建本地私有仓库 使用私有仓库有许多优点 xff1a 一 节省网络带宽 xff0c 针对于每个镜像不用每个人都去中央仓库
  • 斐波那契数列 Java实现

    关于斐波那契数列在百度百科上的定义如下 xff1a 斐波那契数列 xff0c 又称黄金分割数列 xff0c 指的是这样一个数列 xff1a 0 1 1 2 3 5 8 13 21 34 在数学上 xff0c 斐波纳契数列以如下被以递归的方法
  • Maven+Jetty运行项目无法热修改html处理

    一直以来都在做后端工程的开发 xff0c 很少做前端设计 xff0c 最近工作需要开始做前端开发 xff0c 感觉 辛辛苦苦几十年 xff0c 一朝回到解放前 的节奏啊 xff0c 遇到不少问题 xff0c 记录下来以备后查 今天在使用Ma
  • Spring4.3.0 Junit4.11 initializationError(org.junit.runner.manipulation.Filter)

    Spring4 3 0 Junit4 11 initializationError org junit runner manipulation Filter 昨天手欠 xff0c 在项目中把Spring3 2 14版本升级到4 3 0版本
  • zookeeper入门(一)——ZooKeeper伪集群安装

    zookeeper入门 xff08 一 xff09 ZooKeeper伪集群安装 在进行本篇文章之前 xff0c 先请大家了解一下zookeeper xff08 后面的文章为了省事有可能直接使用zk缩写来替代 xff09 xff0c 关于z
  • zookeeper入门(二)——zk客户端脚本使用

    zookeeper入门 xff08 二 xff09 zk客户端脚本使用 在上一篇文章zookeeper入门 xff08 一 xff09 ZooKeeper伪集群安装我们讲了在单机进行zk伪集群安装 xff0c 本篇文章我们来讲一下zk提供的
  • 事务基础知识

    数据库事务 数据库事务定义 xff0c 满足4个特性 xff1a 原子性 xff08 Atomic xff09 一致性 xff08 Consistency xff09 隔离性 xff08 Isolation xff09 和持久性 xff08
  • MySQL事务隔离级别

    1 MySQL所支持的事务隔离级别 MySQL所支持的事务隔离级别 xff1a READ UNCOMMITTED READ COMMITTED REPEATABLE READ SERIALIZABLE 其中 REPEATABLE READ是
  • Thrift第一个示例

    第一步 xff1a 引入thrift依赖包 compile span class hljs keyword group span span class hljs string 39 org apache thrift 39 span nam
  • FreeRTOS系列|计数信号量

    计数信号量 1 计数信号量简介 计数型信号量有以下两种典型用法 事件计数 xff1a 每次事件发生 xff0c 事件处理函数将释放信号量 xff08 信号量计数值加1 xff09 xff0c 其他处理任务会获取信号量 xff08 信号量计数
  • Redis学习——01.redis安装

    下载 tar xzvf redis span class hljs number 3 2 span span class hljs number 10 span span class hljs preprocessor tar span s
  • IDEA常用设置

    显示主题 建议使用Darcula Appearance gt Theme 编辑器字体 建议使用Courier New或者Consolas Editor gt Font gt Font 打开自动编译 Compiler gt Build pro
  • Windows下执行Linux命令

    常用的工具 Cygwin xff08 http www cygwin com xff09 Cygwin是一个在windows平台上运行的类UNIX模拟环境 xff0c 详细参见百度百科 xff1a https baike baidu com
  • Linux网络编程 - 多线程服务器端的实现(1)

    引言 本来 xff0c 线程在 Windows 中的应用比在 Linux 平台中的应用更广泛 但 Web 服务的发展迫使 UNIX 系列的操作系统开始重视线程 由于 Web 服务器端协议本身具有的特点 xff0c 经常需要同时向多个客户端提
  • 访问带有用户名、密码保护的 URL

    一 URL xff0c 统一资源定位器 指向互联网上的 资源 xff0c 可协议名 主机 端口和资源组成 如 http username password 64 host 8080 directory file query ref Comp
  • 【RT-Thread】STM32F1片内Flash实现Bootloader

    目录 前言1 开发环境搭建2 Bootloader制作3 APP程序制作4 OTA固件打包5 Ymodem升级小结 前言 RT Thread官网对于Bootloader的实现方案有非常详细的描述 xff0c 目前支持F1 F4 L4系列单片
  • SDVOE和传统矩阵的区别

    SDVOE最显著的特点 xff1a 分辨率高 xff0c 最高支持4KP60 4 4 4 图像质量好 xff0c 完全可以达到无压缩效果延时小 xff0c Genlock模式下4K30延时只有不到0 1ms xff0c 链路上嵌入千兆网络

随机推荐

  • GD32的DMA配置

    参考 GD32F4xx 用户手册 DMA 控制器由 4 部分组成 xff1a AHB 从接口配置 DMA xff1b 两个 AHB 主接口进行数据传输 xff1b 两个仲裁器进行 DMA 请求的优先级管理 xff1b 数据处理和计数 DMA
  • nuttx杂记

    1 设置自启动应用 修改deconfig文件下的 CONFIG INIT ENTRYPOINT 参数即可 2 消息队列使用 以下是Nuttx系统中使用queue create函数创建队列的示例代码 xff1a include lt stdi
  • linux下使用jlink 调试 stm32的破事

    安装libusb sudo apt get install libusb 安装readline wget c ftp ftp gnu org gnu readline readline 6 2 tar gz tar zxvf readlin
  • FreeRTOS系列|软件定时器

    软件定时器 MCU一般都自带定时器 xff0c 属于硬件定时器 xff0c 但是不同的MCU其硬件定时器数量不同 xff0c 有时需要考虑成本的问题 在硬件定时器不够用的时候 xff0c FreeRTOS也提供了定时器功能 xff0c 不过
  • 视频芯片选择

    常用的视频芯片记录 HDMI TI ITE Explore Silicon image ADI semtech https www semtech com Realtek MACRO http www mitinc co kr module
  • 眼图里的那些破事

    1 眼图基本概念 1 1 眼图的形成原理 眼图是一系列数字信号在示波器上累积而显示的图形 xff0c 它包含了丰富的信息 xff0c 从眼图上可以观察出码间串扰和噪声的影响 xff0c 体现了数字信号整体的特征 xff0c 从而估计系统优劣
  • IIC的地址

    7位寻址 在7位寻址过程中 xff0c 从机地址在启动信号后的第一个字节开始传输 xff0c 该字节的前7位为从机地址 xff0c 第8位为读写位 xff0c 其中0表示写 xff0c 1表示读 图1 xff1a 7位寻址 I2C总线规范规
  • ODR, BSRR, BRR的差别

    ODR寄存器可读可写 xff1a 既能控制管脚为高电平 xff0c 也能控制管脚为低电平 管脚对于位写1 gpio 管脚为高电平 xff0c 写 0 为低电平 BSRR 只写寄存器 xff1a color 61 Red 既能控制管脚为高电平
  • ACAP究竟是什么

    Xilinx推出Versal系列 xff0c 号称业界首款ACAP xff0c 自适应计算加速平台 ACAP不仅是一个新的处理器 xff0c 而且是新的产品类型 作为率先推出ACAP这样类型产品的公司 xff0c 这也是赛灵思的核心竞争力所
  • ISE 14.7 调试错误笔记

    1 ERROR Pack 2530 The dual data rate register 34 U sys ctl ODDR2 inst 2 34 failed to join an OLOGIC component as require
  • HDMI 4K分辨率 时序

    参考 HDMI1 4标准 High Definition Multimedia Interface Specification 这份文件放在百度网盘共享了 xff0c 上传到文档平台会被封禁 xff0c 如果侵权 xff0c 麻烦联系我删除
  • 深度学习CPU,GPU,NPU,TPU以及其计算能力单位

    处理器运算能力单位 TOPS是Tera Operations Per Second的缩写 xff0c 1TOPS代表处理器每秒钟可进行一万亿次 xff08 10 12 xff09 操作 与此对应的还有GOPS xff08 Giga Oper
  • SSD数据集增强方法

    coding utf 8 import numpy as np import random import cv2 import glob import os import xml etree cElementTree as ET def r
  • 目标检测图像增强

    https blog csdn net wei guo xd article details 74199729 常用的图像扩充方式有 xff1a 水平翻转 xff0c 裁剪 xff0c 视角变换 xff0c jpeg压缩 xff0c 尺度变
  • FreeRTOS系列|低功耗管理

    低功耗管理 很多应用场合对于空耗的要求很严格 xff0c 比如可穿戴低功耗产品 物联网低功耗产品等 一般MCU都有相应的低功耗模式 xff0c 裸机开发时可以使用MCU的低功耗模式 FreeRTOS也提供了一个叫Tickless的低功耗模式
  • PELCO-D

    https blog csdn net subfate article details 36644419 在搞visca的同时顺便也搞了pelco 这里再做个笔记 pelco xff0c 中文翻译为 派尔高 xff0c 在行文和写代码过程
  • 图像去模糊算法 deblur

    图像去模糊算法 循序渐进 附完整代码 https www cnblogs com cpuimage p 9735150 html xff08 后面要对比smartdeblur xff0c deblur gan xff09 关于图像模糊算法的
  • 点云数据文件常用格式

    点云数据文件常用格式 文件类型汇总 OFF Object File FormatPLY Polygon File Format also known as the Stanford Triangle FormatPTS Laser scan
  • deeplab介绍

    论文 Encoder Decoder with Atrous Separable Convolution for Semantic Image Segmentation 链接 https www paperweekly site paper
  • 皱纹检测Wrinkle-detection

    基于图像处理的皱纹检测算法 https github com bulingda Wrinkles detection blob master Wrinkle py 基于RCNN 毛孔检测 https github com jack16888