A=imread('test.bmp');
imshow(A);
2. 图像写入
A=imread('test.bmp');
imwrite(A,'test-bak.bmp');
B=imread('test-bak.bmp');
imshow(B);
3. 图像文件信息查询
info=imfinfo('test.bmp');
4. 显示图像
imshow()
RGB=imread('test.bmp');
I=rgb2gray(RGB);
h=[1 2 1;0 0 0;-1 -2 -1];
I2=filter2(h,I);
imshow(I2,[]),colorbar('vert')
6. 纹理映射wrap
A=imread('test.bmp');
I=rgb2gray(A);
[x,y,z]=sphere;
warp(x,y,z,I);
RGB=imread('test.bmp');
I=rgb2gray(RGB);
subplot(1,2,1),subimage(RGB);
subplot(1,2,2),subimage(I);
RGB=imread('test.bmp');
J=imadd(RGB,100); %增加亮度
subplot(1,2,1),subimage(RGB);
subplot(1,2,2),subimage(J);
2. 减法imsubtract
I=imread('test.bmp');
J=imsubtract(I,100);
subplot(1,2,1),subimage(I);
subplot(1,2,2),subimage(J);
3. 乘法immultiply
I=imread('test.bmp');
J=immultiply(I,0.5); %将值缩小0.5,变暗
sublpot(1,2,1),subimage(I);
subplot(1,2,1),subimage(I);
subplot(1,2,2),subimage(J);
4. 除法imdivide
I=imread('test.bmp');
J=imdivide(I,0.5); %除以0.5,值变大,亮度变亮
subplot(1,2,1),subimage(I);
subplot(1,2,2),subimage(J);
I=imread('test.bmp');
X1=imresize(I,2); %放大,宽高扩大两倍
figure,imshow(I);
2. 旋转imrotate
I=imread('test.bmp');
J=imrotate(I,45,'bilinear'); %旋转45°,后面是使用的算法
subplot(1,2,1),subimage(I);
subplot(1,2,2),subimage(J);
3. 裁剪imcrop
I=imread('test.bmp');
J=imcrop(I,[75 68 130 112]); %裁剪区域
subplot(1,2,1),subimage(I);
subplot(1,2,2),subimage(J);
I=imread('test.bmp');
c=[200 250 278 248 199 172];
r=[21 21 75 121 121 75];
BW=roipoly(I,c,r);
subplot(1,2,1),subimage(I); %1行2列的图像
subplot(1,2,2),subimage(BW);
2. 灰度区域选择roicolor
a=imread('test.bmp');
I=rgb2gray(a);
BW=roicolor(I,128,225);
subplot(1,2,1),subimage(I);
subplot(1,2,2),subimage(BW);
x=[63 186 54 190 63];
y=[60 60 209 204 60];
bw=poly2mask(x,y,256,256);
imshow(bw);
hold on
plot(x,y,'b','LineWidth',2)
hold off
4. roifillt2函数实现区域滤波
5. roifill 函数实现对特定区域进行填充
a=imread('test.bmp');
I=rgb2gray(a);
figure;imshow(I); %原始图像
title('Original Image');
PSF=fspecial('motion',13,45); %运动模糊
figure;imshow(PSF); %真实的PSF图像
Blurred=imfilter(I,PSF,'circ','conv'); %得到运动模糊图像
figure;imshow(Blurred);title('Blurred Image'); %模糊化的图像
INITPSF=ones(size(PSF));
[J,P]=deconvblind(Blurred,INITPSF,30); %使用盲卷积
figure;imshow(J); %盲卷积初步复原的图像
%figure;imshow(P,[],'notruesize'); %旧版本
figure;imshow(P,[],'InitialMagnification','fit'); %初步重建使用的PSF
上一篇:Vue框架背后的故事
下一篇:二叉树跟前缀、中缀、后缀表达式