找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4171|回复: 0
收起左侧

FPGA的Sobel算法的实现(Verilog+MATLAB+C源码)

[复制链接]
ID:319108 发表于 2018-4-29 20:56 | 显示全部楼层 |阅读模式
FPGA的Sobel算法的实现 Verilog+MATLAB+C
0.png

matlab边缘检测源程序如下:
  1. % CS638-1 Matlab Tutorial
  2. % TA: Tuo Wang
  3. % tuowang@cs.wisc.edu
  4. % Feb 12th, 2010

  5. clear
  6. clc
  7. % Sobel operator:
  8. % read image
  9. lena = imread('abs.jpg');     
  10. % convert it into double type
  11. lena = double(lena);
  12. % get the dimensional information
  13. height = size(lena, 1);
  14. width = size(lena, 2);
  15. channel = size(lena, 3);
  16. % output image
  17. lenaOutput = zeros(size(lena));
  18. % kernels
  19. % Gx = [1 2 1; 0 0 0; -1 -2 -1];
  20. % Gy = [1 0 -1; 2 0 -2; 1 0 -1];
  21. Gx=[-1 0 1;-2 0 2;-1 0 1];
  22. Gy=[1 2 1;0 0 0;-1 -2 -1];
  23. % compute for every pixel
  24. for i = 2 : height - 1
  25.    for j = 2 : width - 1
  26.        for k = 1 : channel
  27.            tempLena = lena(i - 1 : i + 1, j - 1 : j + 1, k);
  28.            x = sum(sum(Gx .* tempLena));
  29.            y = sum(sum(Gy .* tempLena));
  30.            pixValue = sqrt(x^2 + y^2);
  31.            lenaOutput(i, j, k) = pixValue;
  32.        end
  33.    end
  34. end
  35. % display the processed image
  36. lenaOutput = uint8(lenaOutput);
  37. figure;
  38. imshow(lenaOutput);
  39. title('Sobel Edge Detection');
  40. % write the output to disk
  41. imwrite(lenaOutput, 'lenaOutput.jpg', 'jpg')

  42. % original image
  43. figure;
  44. imshow(uint8(lena));
  45. title('Original Image');
复制代码
0.jpg
所有资料51hei提供下载:
程序代码=Verilog+MATLAB+C.rar (9.86 MB, 下载次数: 47)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表