资源描述:
《matlab实现jpeg算法进行图像压缩的源代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、functionjpeg%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%THISWORKISSUBMITTEDBY:%%%%OHADGAL%%%%%%%%%%%%
2、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%closeall;%==================%section1.2+1.3%==================%thefollo
3、winguseofthefunction:%%plot_bases(base_size,resolution,plot_type)%%willplotthe64wantedbases.Iwilluse"zero-padding"forincreasedresolution%NOTETHATTHESEARETHESAMEBASES!%forreferenceIplotthefollowing3graphs:%a)3Dplotwithbasicresolution(64plotsof8x8pixels)using"surf"fu
4、nction%b)3Dplotwithx20resolution(64plotsof160x160pixels)using"mesh"function%c)2Dplotwithx10resolution(64plotsof80x80pixels)using"mesh"function%d)2Dplotwithx10resolution(64plotsof80x80pixels)using"imshow"function%%NOTE:matrixsizeofpictures(b),(c)and(d),cansupporthig
5、herfrequency=higherbases%butIamnotaskedtodrawthese(higherbases)inthissection!%thezeropaddingisusedONLYforresolutionincrease!%%getallbasepictures(3Dsurfacefigure)plot_bases(8,1,'surf3d');%getallbasepictures(3Dsurfacefigure),x20resolutionplot_bases(8,20,'mesh3d');%ge
6、tallbasepictures(2Dmeshfigure),x10resolutionplot_bases(8,10,'mesh2d');%getallbasepictures(2Dmeshfigure),x10resolutionplot_bases(8,10,'gray2d');%==================%section1.4+1.5%==================%foreachpicture{'0'..'9'}performa2dimensionaldcton8x8blocks.%savethed
7、ctinsideacellofthesize:10cellsof128x128matrix%showforeachpicture,it'sdct8x8blocktransform.foridx=0:9%loadapictureswitchidxcase{0,1},input_image_128x128=im2double(imread(sprintf('%d.tif',idx),'tiff'));otherwise,input_image_128x128=im2double(imread(sprintf('%d.tif',i
8、dx),'jpeg'));end%performDCTin2dimensionoverblocksof8x8inthegivenpicturedct_8x8_image_of_128x128{idx+1}=image_8x8_block_dct(input_image_128x128);i