Matlab梯度法图像锐化

news/2024/7/8 5:28:01 标签: matlab, structure, callback, function, 图形, file

 [I,map]=imread('img1.bmp');   %读入图像
imshow(I,map);                  %显示原图像
I=double(I);                      %转换为double类型
[Gx,Gy]=gradient(I);                 % 计算梯度
G=sqrt(Gx.*Gx+Gy.*Gy);           % 水平垂直差分
J=I;
K=find(G>=7);                   %指定灰度级
J(K)=255;
figure,imshow(J,map);              % 显示处理后的图像

 

转自:http://zhidao.baidu.com/question/160216024.html

 

01function ruihua_Callback(hObject, eventdata, handles)

02% hObject    handle to Untitled_1 (see GCBO)
03% eventdata  reserved - to be defined in a future version of MATLAB
04% handles    structure with handles and user data (see GUIDATA)
05global img1;
06axes(handles.axes1);
07[fname,fpath]=uigetfile('*.bmp;*.jpg','open a file');
08filename=[fpath,fname];
09[I,map]=imread(filename);
10imshow(I,map);
11I=double(I);
12[Gx,Gy]=gradient(I);       % 计算梯度
13G=sqrt(Gx.*Gx+Gy.*Gy);   % 注意是矩阵点乘
14  
15J1=G;                  % 第一种图像增强
16  
17J2=I;                   % 第二种图像增强
18K=find(G>=7);
19J2(K)=G(K);
20  
21  
22J3=I;                   % 第三种图像增强
23K=find(G>=7);
24J3(K)=255;
25  
26J4=I;                   % 第四种图像增强
27K=find(G<=7);
28J4(K)=255;
29  
30  
31J5=I;                   % 第五种图像增强
32K=find(G<=7);
33J5(K)=0;
34Q=find(G>=7);
35J5(Q)=255;
36  
37figure,                 %显示图形
38subplot(2,3,1),imshow(I,map);
39title('原图像');
40subplot(2,3,2),imshow(J1,map);
41title('第一种');
42subplot(2,3,3),imshow(J2,map);
43title('第二种');
44subplot(2,3,4),imshow(J3,map);
45title('第三种');
46subplot(2,3,5),imshow(J4,map);
47title('第四种');
48subplot(2,3,6),imshow(J5,map);
49title('第五种');

转自:http://www.oschina.net/code/snippet_104512_4395


http://www.niftyadmin.cn/n/1174505.html

相关文章

Angular Service入门

1.Angular内置service Angular为了方便开发者开发&#xff0c;本身提供了非常多的内置服务。可以通过https://docs.angularjs.org/api/ng/service查看AngularJS提供的内置服务。在企业级开发中&#xff0c;常用的服务有以下这些&#xff1a; $cacheFactory 缓存服务$compile 编…

交换机端口err-disable、配置速率和双工模式

实例&#xff1a;和客户IDC机房拉了一条MSTP线路&#xff0c;接入到Cisco 3750x后端口灯不亮&#xff0c;更换了端口也是不亮&#xff0c;查看端口信息发现因为客户端有环路导致我们接口出现err-disable错误。故障现象&#xff1a;线路不通&#xff0c;物理指示灯不亮&#xff…

直方均衡,平滑,锐化

直方均衡&#xff0c;平滑&#xff0c;锐化Aimread(18.jpg); Brgb2gray(A); figure,subplot(2,2,1),imshow(B); subplot(2,2,2),imhist(B); A1imadjust(B,[0.2 0.5],[]); subplot(2,2,3),imshow(A1); subplot(2,2,4),imhist(A1); Cimnoise(B,salt & pepper); h1[0.1 0.1 0.…

CVPR2017-目标检测相关

&#xff08;1&#xff09;Speed/accuracy trade-offs for modern convolutional object detectors 其主要考虑三种检测器&#xff08;Faster RCNN,R-FCN,SSD&#xff09;作为元结构&#xff0c;三种CNN网络&#xff08;VGG&#xff0c;Inception&#xff0c;ResNet&#xff09…

28机械臂

https://www.bilibili.com/video/BV1H7411173R/?spm_id_from333.999.0.0 https://www.electrondust.com/2018/11/11/esp-32-micro-robot-arm/#more-318 https://www.instructables.com/ESP32-Micro-Robot-Arm/ https://www.bilibili.com/video/BV1H7411173R/?spm_id_from3…

MATLAB laplace梯度算法

首先&#xff0c;使用fspecial(T,P)产生一个laplace算子。 h1fspecial(laplacian)%laplacian代表laplace滤波器 其次&#xff0c;进行滤波 Aimread(1.bmp);Bimfilter(A,h1); subplot(1,2,1),imshow(A); subplot(1,2,2),imshow(B);

【批处理学习笔记】第九课:批处理符号(2)

四、|这是一个管道传输命令&#xff0c;意思是将上一命令执行的结果传到下一个命令去处理例如&#xff1a;dir c:\|find "txt"以上命令是&#xff1a;查找C&#xff1a;\所有&#xff0c;并发现TXT字符串。FIND的功能请用 FIND /? 自行查看在不使format的自动格式化…