- from matlab官网
- 数字图像处理(matlab本科教学版)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| x = 1 : 2 : 10
x = linspace(1,10,5)
x = x'
randn(3,4) plot(v1,'ro','LineWidth',3) legend('a','b','c') numel(x)
save finename variable,
load filename
v = v1(v1 < 4)
import data
data(:,end)
+-自带broadcast [vM idx] = max(v)
if true ... else ... end
for i = 1:3 ... end
|
数字图像处理
Matlab语法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| gmean = @(A) prod(A, 1)^(1/size(A,1))
varargin varargin{:}
n = nargin
[X, Y] = meshgrid(row_low:row_high, column_low:column_high); f = sin(a * X + b * Y);
D = hypoy(U, V)
I = find(A); [r, c] = find(A); [r, c, v] = find(A);
|
plot相关
线模式 p35
1 2 3 4 5 6
| axis([0 255 0 15000])
set(gca, 'xtick', [0:50:255])
axis tight
|
mesh相关
1 2 3 4 5 6 7 8 9
| % set color colormap([0,0,0]); % 关闭网格 grid off /on % 关闭坐标轴 axis off /on % 观测点角度 view(az, el); view(3) % 把当前设为默认
|
surf相关
灰度变换空间滤波
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| g = imadjust(f, [low_in, high_in], [low_out, high_out], gamma)
Low_high = stretchlim(f)
g = imcomplement(f)
g = im2uint8(mat2gray(log(1+double(f))));
p = imhist(f, b=2) / numel(f)
g = histeq(f,nlev = 64) g = histeq(f,hspec)
g = imfilter(f, w, 'replicate')
gmean = @(A) prod(A, 1)^(1/size(A,1)); f = padarray(f,[m n],'replicate'); g = colfilt(f, [m n],'sliding',@gmean); [M N] = size(f);g = g((1:M) + m, (1:N) + n);
w = fspecial('type',parameters);
g = ordfilt2(f,order,domain);
g = ordfile2(f, (m*n+1)/2, ones(m,n)); g = medfilt2(f);
g = ordfile2(f, 1, ones(m,n));
g = ordfile2(f, m*n, ones(m,n));
|
频率域滤波
$$
F(u,v) = \sum{x=0}^{M-1}\sum{y=0}^{N-1}f(x,y)e^{-j2\pi(ux/M+vy/N)} \f(x,y) = \sum{u=0}^{M-1}\sum{v=0}^{N-1}F(u,v)e^{j2\pi(ux/M+vy/N)}
$$
1 2 3 4 5 6 7 8 9 10 11 12 13
| F = fft2(f); F = fft2(f, P, Q); S = abs(F); f = ifft2(F);
h = fspecial('sobel'); gs = imfilter(f, h);
PQ = paddedsize(size(f)); H = ifftshift(freqz2(h,PQ(1),PQ(2))); gf = dftfilt(f,H);
|
图像复原与重建
1 2 3 4 5 6 7 8
| g = imnoise(f, type, parameters)
f = checkerboard(8);
frest = deconvwnr(g, PSF);
J = edgetaper(I, PSF);
|