1. 首先是灰度图腐蚀
function eroder = gray_erode(img, stel)
img = double(img);
[rows, cols] = size(img);
[irow, icol] = size(stel);
sortrow = ceil(irow/2);
sortcol = ceil(icol/2);
%扩展边界
tempimg1 = [fliplr(img(:, 2:sortcol)), img, fliplr(img(:, end-sortcol+1:end-1))];
tempimg = [flipud(tempimg1(2:sortrow, :)); tempimg1; flipud(tempimg1(end-sortrow+1:end-1, :))];
clear tempimg1;
%开始腐蚀
eroder = img;
for i = sortrow:rows+sortrow-1
for j = sortcol:cols+sortcol-1
win = tempimg(i-sortrow+1:i+sortrow-1, j-sortcol+1:j+sortcol-1);
eroder(i-sortrow+1, j-sortcol+1) = min( min(win+stel) );
end
end
eroder( eroder<0 ) = 0;
end
2. 灰度图膨胀
function dilater = gray_dilate(img, stel)
img = double(img);
[rows, cols] = size(img);
[irow, icol] = size(stel);
sortrow = ceil(irow/2);
sortcol = ceil(icol/2);
%扩展边界
tempimg1 = [fliplr(img(:, 2:sortcol)), img, fliplr(img(:, end-sortcol+1:end-1))];
tempimg = [flipud(tempimg1(2:sortrow, :)); tempimg1; flipud(tempimg1(end-sortrow+1:end-1, :))];
clear tempimg1;
%开始膨胀
dilater = img;
for i = sortrow:rows+sortrow-1
for j = sortcol:cols+sortcol-1
win = tempimg(i-sortrow+1:i+sortrow-1, j-sortcol+1:j+sortcol-1);
dilater(i-sortrow+1, j-sortcol+1) = max( max(win+stel) );
end
end
end
安装 pre-commitpip install pre-commit写 .pre-commit-config.yaml配置文件# See https://pre-commit.com for more information# See https://pre-commit.com/hooks.html for more hooks# pre-commit==2.13.0repos: - repo: https://github.com/pre-commit/pre-commit-hook
原文地址:http://edsionte.com/techblog/archives/3014 QTableWidget类提供了一种基于条目(item)的表格视图模型,在该部件中数据以item为基本单位,每条数据(item)对应一个QTableWidgetItem类的对象,所有数据形成的item组成整个表格。接下来我们创建一个用来显示学生信息的表格,以此为例说明TableWidget的一
//判断是否首次下载在程序启动的时候app delegate 中先判断- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { BOOL isFirst=[[NSUserDefaultsst
120多套各种类别微信小程序模板源码,模板源码打包下载 内附风格截图。先上图:链接:https://pan.baidu.com/s/1DlhP-mrumMNkhH8gVNDS8w提取码: z59m
随着移动开发的火热,安全随之也越来越重要,各种加密md5,AES,sha1,RSA,加密方法,还有https 加密协议等,此文记录下平时用到的加密方法用来记录sha1 加密;md5;base64AESRSA 目前自己学习用到的就这6中,以后用到的还会补充,sha1,md5,base64 写在一起,里面用到的GTMBase64 自己可以下载- (NSString*) sha1{
为什么80%的码农都做不了架构师?>>> ...
Problem 2260 Card GameAccept: 82 Submit: 380Time Limit: 3000 mSec Memory Limit : 32768 KB Problem Description有如下取牌游戏:1. 桌面上有n张卡牌从左到右排成一行,每张卡牌上有一个数字;2. 游戏按轮次进行,每一轮中取掉所有比左边数值小的
基本理论转自::http://blog.csdn.net/sunxianghuang/article/details/51982979泛型数组的实现转自::http://blog.csdn.net/yi_Afly/article/details/52058708请原谅我把大佬们的博客copy到一起...
pydoc在早期的版本支持不是非常好,想打印help('modules')要更新,要是不想更新,可尝试此办法直接打印出来,把pydoc中的东西给扒出来了。import sys, os, impdef pathdirs(): """Convert sys.path into a list of absolute, existing, unique paths."""
信号: 基本概念可重入、线程安全以及异步信号安全的区别? 参考可重入、线程安全和异步信号安全,需要强调的是异步信号安全,这个概念知道的人不多,平常大家在编写代码的时候也很少考虑这个因素,也不清楚哪些函数是异步信号安全的,哪些不是,典型的像printf就不是异步信号安全的,内部会加锁,但是平时很多人都喜欢在信号处理函数中调用。大多数情况下都不会出现问题的,所以让使用者错误的认为这是正确的写法。第
今天分享一个刚刚完成的Python脚本,一个实用的小技能,就是利用Python代码,将EXCEL表格数据导入到MySQL数据库中!话不多说,下面代码示例。Excel表格数据.jpg1示例代码:import xlrdimport pymysql#打开数据所在的工作簿,以及选择存有数据的工作表book = xlrd.open_workbook("students.xls")shee...