Digital Image Processing - MATLAB-0

Gonzalez - Digital Image Processing MATLAB - Standing on the Shoulders of Giants - Study Notes

http://www.imageprocessingplace.com/

2.1
MATLAB Image Processing Toolbox IPT is a function set that expands the numerical computing capabilities of MATLAB. The image x and y coordinates and amplitudes are continuous, and the first step in digitization is digitization. The digitization of coordinate values ​​is called sampling or sampling , and the digitization of amplitude is called quantization . The general image coordinate origin is (0, 0), and the image coordinate representation of Matlab's IPT toolbox is (1, 1). Stored in a matrix variable.
write picture description here
2.2 The reading and display of images in Matlab are maintained
write picture description here

imread('fiilename');#不加分号会立即显示图像,加分号表示取消输出。
 #eg:f=imread('dog.png');
 size(f);#给出图像的行数和列数
 [M,N]=size(f);#获取行数和列数
 whos f#显示数组f的信息。
 imshow(f);#默认显示彩色图
 imshow(g);#再次用imshow会覆盖掉前面的f图像的显示,可以用figure函数取代
 figure,imshow(g);
 imshow(f,G);#显示图像f的灰度图
 imshow(f,[low,high]);#显示图像f的灰度图,小于low的显示为黑色,大于等于high的显示为白色,介于两者之间的显示为中等亮度值
 imwrite(f,'copyf.png');#保存图像
 imfinfo filename#显示图像文件信息
 k=imfinfo('dog.jpg');#图像信息保存到k中

2.2 The pixel value in the data class Matlab is not an integer,

write picture description here

Brightness image
data matrix, the normalized value represents the brightness, the integer value range of unit8 or unit16 is [0,255] and [0,65535] respectively. The pixel value of the double class is a floating point number. The double-precision normalized brightness value range [0,1]
binary image
has only the values ​​of 0 and 1.

b=logical(c);#c图像二值化。
 islogical(b);#判断b是否是逻辑数组
 b=data_class_name(a);#如 b=double(a);
 g=im2unit8(b);#小于0的转为0,大于1的转为255,之间数字乘以255,并四舍五入为最近的整数。
 d=g.';#d是g的转制
 d(1:3);#取d中前三个元素
 V(1:2:end)#步长为2取值
  V(end:-2:1)#步长为-2取值倒序
  fp=f(end:-1:1,:)#垂直翻转
  fc=f(257:768,257:768)#取图像的一部分
  fs=f(12end,1:2:end);#二次采样
  k=size(A,1)#A的行数
  k=size(A,2)#A的列数

write picture description here

zero(M,N);double类型的0
ones(M,N);
ture(M,N);
false(M,N);逻辑类型
magic(M,N);
rand(M,N);[0,1]randn(M,N);正态分布u(0,1)



write picture description here
write picture description here
2.3 Matlab code optimization
1. Vectorized loop
0 for and while are converted into equivalent vector or matrix operations

for x=1:M
    f(x)=A*sin((x-1)/(2*pi));
end
优化后
x=1:M-1;
f=A*sin(x/(2*pi));

preallocated array

#加快执行时间另一种方法是在程序中**预分配数组的大小**,减少存储器碎片
f=zeros(1024);
g=zeros(1024);

2.4 Interactive I/O
0显示a矩阵disp(a)

t=input('enter your data:','s');#输入1 2 3时t=1 2 3,是char类型的class(t)

n=str2num(t)#转为数字类型
d=char(n)#转为char类型

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324722212&siteId=291194637