当前位置:文档之家› 数字图像处理 Matlab版 作业1

数字图像处理 Matlab版 作业1


>> K50=imfinfo('image2-50.jpg'); image_byte_50=K50.Width*K50.Height*K50.BitDepth/8; CMP_bytes=K50.FileSize; CMP_R50=image_byte_50/CMP_bytes CMP_R50 = 10.6149 %绘图 1
>> y=[MSE0,MSE1,MSE2,MSE3,MSE4,MSE5]; >> x=[0,10,20,30,40,50]; >> plot(x,y) >> SNR0=10*LOG10(255^2/MSE0)
Warning: Could not find an exact (case-sensitive) match for 'LOG10'.
C:\Program Files\MATLAB\R2009a\toolbox\matlab\elfun\log10.m is a case-insensitive match and will be used instead. You can improve the performance of your code by using exact name matches and we therefore recommend that you update your usage accordingly. Alternatively, you can disable this warning using warning('off','MATLAB:dispatcher:InexactCaseMatch'). This warning will become an error in future releases.
>>y1=[SNR0,SNR10,SNR20,SNR30,SNR40,SNR50]; y2=[MSE0,MSE1,MSE2,MSE3,MSE4,MSE5]; x=[0,10,20,30,40,50]; plot(x,y1,x,y2) >> y1=[SNR0,SNR10,SNR20,SNR30,SNR40,SNR50]; y2=[MSE0,MSE1,MSE2,MSE3,MSE4,MSE5]; x=[0,10,20,30,40,50]; plot(x,y1,x,y2)
%A、B 是作为图片的变量
>> B1=imread('image2-10.jpg'); >> MSE=sum((A(:)-B1(:)).^2)/(M*N) MSE = 31.3642
>> B2=imread('image2-20.jpg'); MSE=sum((A(:)-B2(:)).^2)/(M*N) MSE = 20.3310
SNR0 =
30.2372
>> SNR10=10* LOG10(255^2/MSE1) SNR10 = SNR20 = 33.1665 35.0492 >> SNR20=10* LOG10(255^2/MSE2) >> SNR30=10* LOG10(255^2/MSE3) SNR40=10* LOG10(255^2/MSE4) SNR50=10* LOG10(255^2/MSE5) SNR30 = SNR40 = SNR50 = 36.2051 36.7500 36.9028 %绘图 2
Warning: Image is too big to fit on screen; displaying at 67% >> Imshow(b) Warning: Image is too big to fit on screen; displaying at 67% > In imuitools\private\initSize at 73 In imshow at 262 >> [M,N]=size(f) M= N= 960 640
K20=imfinfo('image2-20.jpg'); >> image_byte_20=K20.Width*K20.Height*K20.BitDepth/8; >> CMP_bytes=K20.FileSize; >> CMP_R20=image_byte_20/CMP_bytes CMP_R20 = 16.9368
>>
40 30 20 10 0 0 10 20 30 40 50
>>subplot(2,1,1) bar(x,y1,'stacked') subplot(2,1,2) bar(x,y2,'grouped')
80 60 40 20 0 0 10 20 30 40 50
70
60
50
40
30
20
10 0
y0=[ CMP_R0, CMP_R10, CMP_R20, CMP_R30, CMP_R40, CMP_R50]; >> x0=[0,10,20,30,40,50]; >> plot(x0,y0)
>> A=imread('image2.jpg'); >> >> B=imread('image2-0.jpg'); >> MSE=sum((A(:)-B(:)).^2)/(M*N) MSE = 61.5688
数字图像处理作业
作业要求:
读入一幅灰度 BMP 图像 : (1)显示读入的 BMP 图像
Matlab
(2)将图像保存为 JPG 文件,质量控制参数分别取值为 0,10,20,30,40,50 (3)显示 q=0 和 50 对应的 JPG 图像 (4)计算不同 q 值对应的压缩比 , 用 plot 函数画出 q 与压缩比的关系曲线 (5)计算不同 q 值对应的信噪比,用 plot 函数画出 q 与信噪比的关系曲线
10
20
30
40
50
>> subplot(1,1,1)
>> plot(x,y1,'b:p',x,y2,'c-')
必要的文字说明
f=imread(‘filename’) 可以读入的文件格式 TIFF\JPEG\BMP\PNG\GIF 参考 :压缩比与信噪比计算 压缩比: 压缩前文件大小/压缩后文件大小 信噪比 : A(i,j)压缩前图像像素值 B(i,j)压缩后图像像素值 用 MATLAB 计算 MSE 计算: MSE=sum((A(:)-B(:)).^2)/(M*N)
>> K40=imfinfo('image2-40.jpg'); image_byte_40=K40.Width*K40.Height*K40.BitDepth/8;
CMP_bytes=K40.FileSize; CMP_R40=image_byte_40/CMP_bytes CMP_R40 = 12.2718
>> K0=imfinfo('image2-0.jpg'); >> image_byte_0=K0.Width*K0.Height*K0.BitDepth/8; >> CMP_bytes=K0.FileSize; >> CMP_R0=image_byte_0/CMP_bytes CMP_R0 = 59.2022
%绘图 1+2
运行结果(图像或曲线)
Image2-0.jpg
Image2-50.jpg
Image2.jpg
60 55 50 45 40 35 30 25 20 15 10
0
5
10
15
20
25
30
35
40
45
50
CMP 图标 压缩比
70
60
50
40
30
20
10 0
10
20
30
40
50
MSE 曲线
37 36 35 34 33 32 31 30 0
>> B3=imread('image2-30.jpg'); MSE=sum((A(:)-B3(:)).^2)/(M*N) MSE = 15.5803
>> B4=imread('image2-40.jpg'); MSE=sum((A(:)-B4(:)).^2)/(M*N)
MSE =
13.7430
>> B5=imread('image2-50.jpg'); MSE=sum((A(:)-B5(:)).^2)/(M*N) MSE = 13.2680 %绘图 1
K10=imfinfo('image2-10.jpg'); >> image_byte_10=K10.Width*K10.Height*K10.BitDepth/8; >> CMP_bytes=K10.FileSize; >> CMP_R10=image_byte_10/CMP_bytes CMP_R10 = 27.0888
K30=imfinfo('image2-30.jpg'); >> image_byte_30=K30.Width*K30.Height*K30.BitDepth/8; >> CMP_bytes=K30.FileSize; >> CMP_R30=image_byte_30/CMP_bytes CMP_R30 = 13.6140
ATLAB 源代码
相关主题