标题: FPGA的Sobel算法的实现(Verilog+MATLAB+C源码) [打印本页]

作者: panweiwen    时间: 2018-4-29 20:56
标题: FPGA的Sobel算法的实现(Verilog+MATLAB+C源码)
FPGA的Sobel算法的实现 Verilog+MATLAB+C


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');
复制代码

所有资料51hei提供下载:
程序代码=Verilog+MATLAB+C.rar (9.86 MB, 下载次数: 47)









欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1