matlab算法到fpga实现流程,膨胀算法的Matlab+FPGA实现

1. Dilation膨胀算法的Matlab实现

咋们家FPGA真是太好了,能做那么多实时处理的算法,在上一步进行边缘检测后,现在进行膨胀(额,我有膨胀了)!!!实现一定程度的噪声的抑制!!!不过这个太特么简单了。。。。我简单说几句吧!!!

1.1. Dilation算法简介

前一章中已经实现了Sobel边缘检测算法,得到了二值图像。但是无法避免的噪声或者背景中的黑点。本章通过介绍Dilation算法的应用,实现对图像的erosion(腐蚀),实现的Sobel算法后的深度优化,让边缘检测更厚重。

7c7726c4abf39cf2d94081d6e7dc1492.png

简而言之,就是通过或运算来膨胀3X3区域,对黑点进行一定的腐蚀,来达到扩张的效果。

1.2. Dilation算法实现

1.2.1. Matlab代码

Sobel求得边缘位0,其他位1。

在Sobel算子的基础上,进行一定程度的腐蚀,算法如下所示,非常简单:

% -----------------------------------------------------------------------

% Dilation Sobel image

IMG_Dilation = true(h,w);     %边缘信息,二值化数据

for i = 2 : h-1             %舍弃了边缘信息

for j = 2 : w-1

IMG_Dilation(i,j) = IMG_Sobel(i-1,j-1)  |   IMG_Sobel(i-1,j)    |   IMG_Sobel(i-1,j+1)  |...

IMG_Sobel(i,j-1)    |   IMG_Sobel(i,j)      |   IMG_Sobel(i,j+1)    |...

IMG_Sobel(i+1,j-1)  |   IMG_Sobel(i+1,j)    |   IMG_Sobel(i+1,j+1);

end

end

1.2.2. 效果图

如下图所示,THRESHOLD = 50下的图像。效果不是很明显因为噪声不是很大。但如果应用在硬件中,对CMOS图像Sobel后进行再处理,那效果可想而知。

39f3f864488614105f3138810a80f6c8.png

以下是FPGA实现,简直不想多说,so native!!

、//---------------------------------------

//Dilation with or operation, step1

regpost_img_Bit_1;

regpost_img_Bit_2;

regpost_img_Bit_3;

always@(posedge clk or negedge rst_n)

begin

if(!rst_n)

begin

post_img_Bit_1 <= 1'b1;//Default White

post_img_Bit_2 <= 1'b1;//Default White

post_img_Bit_3 <= 1'b1;//Default White

end

else

begin

post_img_Bit_1 <= image_p11 | image_p12 | image_p13;

post_img_Bit_2 <= image_p21 | image_p22 | image_p23;

post_img_Bit_3 <= image_p21 | image_p32 | image_p33;

end

end

6683ffaa1b9b4ee433e1e5d2c016cf76.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值