版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
研究生阶段,确定进入了医学图像处理这一个方向。以前只学过图像的基本知识,像什么灰度图啊,rgb啊,灰度直方图等等。没有深入的学习过这方面的知识。
现在打算先学习一些图像处理中一些经典的算法开始,有些简单的算法自己也可以练练手。其实这些经典的算法无论是opencv,matlab都已经有现成的函数可以用,但是我不认为这个徒劳的过程,对这些函数的实现过程,可以学到很多思想,为将来的学习提供很好的基础。
在写这个博文前,我已经学习了几个学习算法,并用笔记本记入下来。今天突发奇想,想来写csdn的博文,希望能坚持下去。
一.LBP 局部二值法。英文全称:Local Binary Patterns。
基本思想:对cell像素周围的像素对比,编码后求和的值取代cell的值,具体的过程可以看下面的图解释
数学公式:
扫描二维码关注公众号,回复:
7657486 查看本文章
变形算法:
将256的个值 归一成59个组合,提高效率
不再以3*3的网格作为一个区域,一更大的矩形,或者圆作为移动窗口
应用:
将检测区域分割成子区域,对每个区域内的pixel取LBP,每个区域建立LBP统计直方图。
代码实现:
ps:代码实现的语言自己选择,matlab和opencv都很方便。
这里贴出matlab的代码
close all;clc ;
src = imread('H:/testimage/11.jpg'); %%地址自己改哦
src =rgb2gray(src);
XY=size(src);
x=XY(1);
y=XY(2);
dst = zeros(x,y) ;
cell_arround=[0,0,0,0,0,0,0,0];
%%cell_arround(8) = src(1,3);
for i=2:x-1
for j=2:y-1
cell_arround(8)=src(i-1,j-1);
cell_arround(7)=src(i-1,j);
cell_arround(6)=src(i-1,j+1);
cell_arround(5)=src(i,j-1);
cell_arround(4)=src(i,j+1);
cell_arround(3)=src(i+1,j-1);
cell_arround(2)=src(i+1,j);
cell_arround(1)=src(i+1,j+1);
cell = src(i,j);
for k=1:8
if cell_arround(k)<cell
cell_arround(k)=0;
end
if cell_arround(k)>=cell
cell_arround(k)=1;
end
end
cell=cell_arround(8)+2*cell_arround(7)+4*cell_arround(6)...
+8*cell_arround(5)+16*cell_arround(4)+32*cell_arround(3)...
+64*cell_arround(2)+128*cell_arround(1);
dst(i,j)=cell;
end
end
figure(1);imshow(src);
figure(2);imshow(dst,[]);