sobel算子

  1. %File Discription:  
  2. %45°和135°角边缘检测;用于那些边界不明显的图片  
  3. %不太适用于复杂图,复杂图用水平和垂直边缘检测  
  4. %Author:Zhang Ruiqing  
  5. %CreateTime:2011.8.8(What a good day!(*^__^*) )  
  6.   
  7. SourcePic=imread('D:\Images\pic_loc\1870378220205041520.jpg');  
  8. subplot(221);  
  9. imshow(SourcePic),title('原图');  
  10.   
  11. grayPic=rgb2gray(SourcePic);  
  12. grayPic=im2double(grayPic);  
  13. %使用指定45度角Sobel算子滤波器,指定阂值  
  14.   
  15. a45=[-2 -1 0;-1 0 1;0 1 2];  
  16. SFST45=imfilter(grayPic,a45,'replicate');%功能:对任意类型数组或多维图像进行滤波。  
  17. SFST45=SFST45>=Threshold;  
  18. subplot(222);  
  19. imshow(SFST45),title('45度角图像边缘检测') ;  
  20.   
  21. b45=[0 -1 -2;1 0 -1;2 1 0];  
  22. SFST45=imfilter(grayPic,b45,'replicate');%功能:对任意类型数组或多维图像进行滤波。  
  23. SFST45=SFST45>=Threshold;  
  24. SFST45  
  25. subplot(223);  
  26. imshow(SFST45),title('135度角图像边缘检测') ;  

[html]  view plain copy
  1. %File Discription:  
  2. %水平、垂直边缘检测;  
  3. %Author:Zhang Ruiqing  
  4. %CreateTime:2011.8.8  
  5.   
  6. SourcePic=imread('D:\毕业设计\Images\pic_loc\1870399350205061354.jpg');  
  7. subplot(221);  
  8. imshow(SourcePic),title('原图');  
  9.   
  10. grayPic=rgb2gray(SourcePic);  
  11. grayPic=im2double(grayPic);  
  12. [Vertical Threshold]=edge(grayPic,'sobel','vertical');%edge detect  
  13. subplot(222);  
  14. imshow(Vertical),title('垂直方向边缘检测');  
  15.   
  16. [Horizontal Threshold]=edge(grayPic,'sobel','horizontal');%edge detect  
  17. subplot(223);  
  18. imshow(Horizontal),title('水平方向边缘检测');  
  19.   
  20. H_V=edge(grayPic,'sobel',Threshold);  
  21. subplot(224);  
  22. imshow(H_V),title('水平和垂直边缘检测');  

				<script>
					(function(){
						function setArticleH(btnReadmore,posi){
							var winH = $(window).height();
							var articleBox = $("div.article_content");
							var artH = articleBox.height();
							if(artH > winH*posi){
								articleBox.css({
									'height':winH*posi+'px',
									'overflow':'hidden'
								})
								btnReadmore.click(function(){
									articleBox.removeAttr("style");
									$(this).parent().remove();
								})
							}else{
								btnReadmore.parent().remove();
							}
						}
						var btnReadmore = $("#btn-readmore");
						if(btnReadmore.length>0){
							if(currentUserName){
								setArticleH(btnReadmore,3);
							}else{
								setArticleH(btnReadmore,1.2);
							}
						}
					})()
				</script>
				</article>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值