![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MATLAB函数Python实现
xtphysics
莱顿大学LUMC在读博士
展开
-
多层文件夹递归的MATLAB和Python实现
MATLAB实现:function scanDir(root_dir)% if isempty(varargin)% root_dir = uigetdir;% end% files={};if root_dir(end)~='\' root_dir=[root_dir,'\'];endfileList=dir(root_dir); %扩展名n=length(fileList);for i=1:n if strcmp(fileList(i).name,'.')==1||原创 2021-07-19 17:53:33 · 223 阅读 · 0 评论 -
大津阈值(otsuthresh)的Python实现
参照《数字图像处理》中对大津阈值的理论描述,Python可如下实现import numpy as npdef otsuthresh(h): h = h/sum(h) i = np.arange(1,h.size+1) P1 = np.cumsum(h) m = np.cumsum(i*h) mG = m[-1] eps = 2.2204*pow(10,-16) sigSquared = np.power((mG*P1-m),2)/(P1*(1-P1原创 2021-07-07 11:39:15 · 1078 阅读 · 0 评论 -
Python实现MATLAB函数regionprops(BW, ‘Extrema‘)功能
Python实现MATLAB函数regionprops(BW, ‘Extrema’)功能Python软件包skimage中的measure.regionprops()与MATLAB函数regionprops()功能相似。返回二值化图像区域顶点坐标MATLAB中使用的是regionprops(BW,‘Extrema’),可以返回八个顶点坐标,如图1所示。而Python中measure.regionprops(BW)[‘bbox’]只返回四个顶点坐标(min_row,min_col,max_row,max_原创 2021-07-07 10:42:58 · 1414 阅读 · 2 评论