91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.81MB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2023-11-18
  • 語言: 其他
  • 標簽: canny??

資源簡介

基于圖像邊緣檢測的Canny算法,梯度幅值和角度,進行非極大值抑制

資源截圖

代碼片段和文件信息

clear;
close?all;
clc;

%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Input?parameters%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
MaskSize?=?3;
Sigma?=?5;???%(for?Gaussian)
Threshold?=?0.30;?%(building?brick?0.13?monkey?0.22?lena0.18?building?outline?)
%?ThresholdRatio?=?0;
ThresholdRatio?=?1e-40;

%==========================================================================
%===================Opening?the?files?of?images============================
%==========================================================================
[filename?pathname]=uigetfile({‘*.jpg‘;...
????‘*.bmp‘;...
????‘*.gif‘;...
????‘*.png‘;...
????‘*.tif‘}...
????‘Open?the?files?of?images‘);
if?filename~=0
????openfilename?=?strcat(pathnamefilename);?%processing?diversified?forms?of?images
????eval([‘info=imfinfo(‘‘‘openfilename?‘‘‘);‘]);
????switch?info.ColorType
????????case?‘truecolor‘
????????????eval([‘RGB?=?imread(‘‘‘openfilename?‘‘‘);‘]);??%[X?map]?=?rgb2ind(RGB?256);
????????????InImg?=?rgb2gray(RGB);
????????????clear?RGB;
????????case?‘indexed‘
????????????eval([‘[X?map]?=?imread(‘‘‘openfilename?‘‘‘);‘]);
????????????InImg?=?ind2gray(X?map);
????????????clear?X;
????????case?‘grayscale‘
????????????eval([‘InImg?=?imread(‘‘‘openfilename?‘‘‘);‘]);
????end
else
????return;
end
st?=?cputime;
%?subplot(211);imagesc(InImg);title(‘lotus?picture‘);
InImg?=?double(InImg);
[rows?cols]?=?size(InImg);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?Calculate?Filtered?Gradient
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

GausDer_x?=?ones(MaskSizeMaskSize);
GausDer_y?=?ones(MaskSizeMaskSize);
Amp=-1/sqrt(2*pi*Sigma);
for?g_x=1:MaskSize;
????for?g_y=1:MaskSize;
????????x?=?g_x-(MaskSize+1)/2;
????????y?=?g_y-(MaskSize+1)/2;
????????GausDer_x(g_xg_y)=Amp*(x/Sigma^2).*exp(-(x^2+y^2)/(2*Sigma^2));
????????GausDer_y(g_xg_y)=Amp*(y/Sigma^2).*exp(-(x^2+y^2)/(2*Sigma^2));???%derivative?of?a?Gaussian
????end
end

GausDer_x(g_xg_y)?=?sum(sum(GausDer_x(g_xg_y)));
GausDer_y(g_xg_y)?=?sum(sum(GausDer_x(g_xg_y)));????%normalization

Img_gx?=?conv2(InImgGausDer_x‘same‘);
Img_gy?=?conv2(InImgGausDer_y‘same‘);

F?=?sqrt(Img_gx.*Img_gx+Img_gy.*Img_gy);??%the?magnitude?of?the?gradient
D?=?atan(Img_gy./Img_gx);?????????????????%edge?orientation?of?the?gradient
figure(1);
subplot(121);
imagesc(F);
title(‘Gradient?Amplitude‘);
subplot(122);
imagesc(D);
title(‘Gradient?Angle‘);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?Nonmaximum?suppression
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

EdgGrad?=?zeros(rows?cols);
EdgDirc?=?zeros(rows?cols);
for?i?=?2:?(rows-1)
????for?j?=?2:?(cols-1)
????????switch?fix(8*D(ij)/pi)
????????????case?0?????????????????????????????????????%?from?0?-?pi/8??and?7pi/8?-pi
??

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-06-09?14:05??53623196Cmp_vis_canny\
?????文件????????7315??2018-06-09?10:56??53623196Cmp_vis_canny\Cmp_vis_canny.m
?????文件???????30046??2018-06-09?11:00??53623196Cmp_vis_canny\edge?detection.jpg
?????文件??????460040??2018-06-09?10:59??53623196Cmp_vis_canny\edge?gradient.fig
?????文件??????136304??2018-06-09?11:00??53623196Cmp_vis_canny\edge?gradient.jpg
?????文件???????11914??2006-08-09?11:57??53623196Cmp_vis_canny\flower.jpg
?????文件?????2120064??2018-06-09?10:57??53623196Cmp_vis_canny\gradient.fig
?????文件??????147180??2018-06-09?11:00??53623196Cmp_vis_canny\gradient.jpg
?????文件???????26152??2018-06-09?10:21??53623196Cmp_vis_canny\lotus.jpg
?????文件???????25586??2018-06-09?11:01??53623196Cmp_vis_canny\untitled.jpg

評論

共有 條評論