(自留备忘)数字图像处理(一)
%随便记一记%
Matlab基本概念
- m文件:为可执行的代码文件(函数文件或脚本文件)
Matlab常见命令
clc | 清除命令窗口显示的内容 |
---|---|
clear | 清除工作空间中的所有变量 |
who | 检查工作空间的变量 |
whos | 检查存于工作空间中变量的的详细资料 |
close | 关闭当前图窗 |
close all | 关闭所有图窗 |
help | 帮助 |
示例
%灰度图像%
clc;clear;close all;
I=imread('宁.jpg'); % 从图形文件读取图像
J=rgb2gray(I); % "rgb to gray",将 RGB 图像或颜色图转换为灰度图
figure,imshow(I);
title('orignal image');
figure,imshow(J); % 重新创建图窗窗口,显示图像
title('grey image'); % 添加标题“grey image”
% 此时I、J均为uint8类型变量,用来存储图片
简单操作
算数运算
几何变换
图像的平移变换(polyshape)
%图像平移%
clc;clear all;close all;
I=imread('nasa1.jpg');
se=translate(strel(1),[25 25]);
% Create a structuring element and translate it down and to the right by 25 pixels.
J=imdilate(I,se);
% Dilate the image using the translated structuring element.
imshow(I),title('Original');
figure,imshow(J),title('Translated');
图像的镜像变换
图像的转置变换
图像的旋转变换
图像的缩放
B=imresize(A,scale);
霍夫变换(Hough Transform)
幂函数变换
%幂函数变换%
clc;clear all; close all;
I=imread('an.jpg');
J=double(I);
J=1.2*power(J,1.2);
H=uint8(J);
subplot(1,2,1),imshow(I);
title('原始图像');
subplot(1,2,2),imshow(H);
title('幂函数变换后图像');
%通过幂函数变换,将暗图片变得更清楚%