亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? jpeg.m

?? MATLAB圖像壓縮JPEG編解碼算法,多種參數(shù)對(duì)比
?? M
字號(hào):
function jpeg

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%      THIS WORK IS SUBMITTED BY:
%%
%%      OHAD GAL
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all;

% ==================
% section 1.2 + 1.3
% ==================
% the following use of the function:    
%
%    plot_bases( base_size,resolution,plot_type )
%
% will plot the 64 wanted bases. I will use "zero-padding" for increased resolution
% NOTE THAT THESE ARE THE SAME BASES !
% for reference I plot the following 3 graphs:
% a) 3D plot with basic resolution (64 plots of 8x8 pixels) using "surf" function
% b) 3D plot with x20 resolution (64 plots of 160x160 pixels) using "mesh" function
% c) 2D plot with x10 resolution (64 plots of 80x80 pixels) using "mesh" function
% d) 2D plot with x10 resolution (64 plots of 80x80 pixels) using "imshow" function
%
% NOTE: matrix size of pictures (b),(c) and (d), can support higher frequency = higher bases
%       but I am not asked to draw these (higher bases) in this section !
%       the zero padding is used ONLY for resolution increase !
%
% get all base pictures (3D surface figure)
plot_bases( 8,1,'surf3d' );

% get all base pictures (3D surface figure), x20 resolution
plot_bases( 8,20,'mesh3d' );

% get all base pictures (2D mesh figure), x10 resolution
plot_bases( 8,10,'mesh2d' );   

% get all base pictures (2D mesh figure), x10 resolution
plot_bases( 8,10,'gray2d' );   



% ==================
% section 1.4 + 1.5
% ==================
% for each picture {'0'..'9'} perform a 2 dimensional dct on 8x8 blocks.
% save the dct inside a cell of the size: 10 cells of 128x128 matrix
% show for each picture, it's dct 8x8 block transform.

for idx = 0:9
   
   % load a picture
   switch idx
   case {0,1}, input_image_128x128 = im2double( imread( sprintf( '%d.tif',idx ),'tiff' ) );
   otherwise, input_image_128x128 = im2double( imread( sprintf( '%d.tif',idx),'jpeg' ) );
   end   
   
   % perform DCT in 2 dimension over blocks of 8x8 in the given picture
   dct_8x8_image_of_128x128{idx+1} = image_8x8_block_dct( input_image_128x128 );

   if (mod(idx,2)==0)
      figure;
   end     
   subplot(2,2,mod(idx,2)*2+1);
   imshow(input_image_128x128);
   title( sprintf('image #%d',idx) );
   subplot(2,2,mod(idx,2)*2+2);
   imshow(dct_8x8_image_of_128x128{idx+1});
   title( sprintf('8x8 DCT of image #%d',idx) );
end



% ==================
% section 1.6
% ==================
% do statistics on the cell array of the dct transforms
% create a matrix of 8x8 that will describe the value of each "dct-base" 
% over the transform of the 10 given pictures. since some of the values are
% negative, and we are interested in the energy of the coefficients, we will
% add the abs()^2 values into the matrix.
% this is consistent with the definition of the "Parseval relation" in Fourier Coefficients

% initialize the "average" matrix 
mean_matrix_8x8 = zeros( 8,8 );

% loop over all the pictures
for idx = 1:10
    
    % in each picture loop over 8x8 elements (128x128 = 256 * 8x8 elements)
   for m = 0:15
      for n = 0:15
         mean_matrix_8x8 = mean_matrix_8x8 + ...
            abs( dct_8x8_image_of_128x128{idx}(m*8+[1:8],n*8+[1:8]) ).^2;
      end
   end
end

% transpose the matrix since the order of the matrix is elements along the columns,
% while in the subplot function the order is of elements along the rows
mean_matrix_8x8_transposed = mean_matrix_8x8';

% make the mean matrix (8x8) into a vector (64x1)
mean_vector = mean_matrix_8x8_transposed(:);

% sort the vector (from small to big)
[sorted_mean_vector,original_indices] = sort( mean_vector );

% reverse order (from big to small)
sorted_mean_vector = sorted_mean_vector(end:-1:1);
original_indices = original_indices(end:-1:1);

% plot the corresponding matrix as asked in section 1.6
figure;
for idx = 1:64
   subplot(8,8,original_indices(idx));
   axis off;
   h = text(0,0,sprintf('%4d',idx));
   set(h,'FontWeight','bold');
   text(0,0,sprintf(' \n_{%1.1fdb}',20*log10(sorted_mean_vector(idx)) ));
end

% add a title to the figure
subplot(8,8,4);
h = title( 'Power of DCT coefficients (section 1.6)' );
set( h,'FontWeight','bold' );



% ==================
% section 1.8
% ==================
% picture 8 is chosen
% In this section I will calculate the SNR of a compressed image againts
% the level of compression. the SNR calculation is defined in the header 
% of the function:  <<calc_snr>> which is given below.
%
% if we decide to take 10 coefficients with the most energy, we will add
% zeros to the other coefficients and remain with a vector 64 elements long
% (or a matrix of 8x8)

% load the original image
original_image = im2double( imread( '8.tif','jpeg' ) );

% I will use this matrix to choose only the wanted number of coefficients
% the matrix is initialized to zeros -> don't choose any coefficient at all
coef_selection_matrix = zeros(8,8);

% compressed picture set (to show the degrading)
compressed_set = [1 3 5 10 15 20 30 40];

% this loop will choose each time, the "next-most-energetic" coefficient, 
% to be added to the compressed image -> and thus to improove the SNR
for number_of_coefficient = 1:64
    
    % find the most energetic coefficient from the mean_matrix
    [y,x] = find(mean_matrix_8x8==max(max(mean_matrix_8x8)));
    
    % select if for the compressed image
    coef_selection_matrix(y,x) = 1;
    
    % replicate the selection matrix for all the parts of the dct transform
    % (remember that the DCT transform creates a set of 8x8 matrices, where
    %  in each matrix I need to choose the coefficients defined by the 
    %  <<coef_selection_matrix>> matrix )
    selection_matrix = repmat( coef_selection_matrix,16,16 );
    
    % set it as zero in the mean_matrix, so that in the next loop, we will
    % choose the "next-most-energetic" coefficient
    mean_matrix_8x8(y,x) = 0;
    
    % choose the most energetic coefficients from the original image
    % (total of <<number_of_coefficient>> coefficients for this run in the loop)
    compressed_image = image_8x8_block_dct(original_image) .* selection_matrix;
    
    % restore the compressed image from the given set of coeficients
    restored_image = image_8x8_block_inv_dct( compressed_image );
    
    % calculate the snr of this image (based on the original image)
    SNR(number_of_coefficient) = calc_snr( original_image,restored_image );
    
    if ~isempty(find(number_of_coefficient==compressed_set))
        if (number_of_coefficient==1)
            figure;
            subplot(3,3,1);
            imshow( original_image );
            title( 'original image' );
        end
        subplot(3,3,find(number_of_coefficient==compressed_set)+1);
        imshow( restored_image );
        title( sprintf('restored image with %d coeffs',number_of_coefficient) );
    end
end

% plot the SNR graph
figure;
plot( [1:64],20*log10(SNR) );
xlabel( 'numer of coefficients taken for compression' );
ylabel( 'SNR [db] ( 20*log10(.) )' );
title( 'SNR graph for picture number 8, section 1.8' );
grid on;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% --------------------------------------------------------------------------------
%%         I N N E R   F U N C T I O N   I M P L E M E N T A T I O N
%% --------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ---------------------------------------------------------------------------------
% pdip_dct2 - implementation of a 2 Dimensional DCT
%
% assumption: input matrix is a square matrix !
% ---------------------------------------------------------------------------------
function out = pdip_dct2( in )

% get input matrix size
N = size(in,1);

% build the matrix
n = 0:N-1;
for k = 0:N-1
   if (k>0)
      C(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N)*sqrt(2);
   else
      C(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N);
   end   
end

out = C*in*(C');

% ---------------------------------------------------------------------------------
% pdip_inv_dct2 - implementation of an inverse 2 Dimensional DCT
%
% assumption: input matrix is a square matrix !
% ---------------------------------------------------------------------------------
function out = pdip_inv_dct2( in )

% get input matrix size
N = size(in,1);

% build the matrix
n = 0:N-1;
for k = 0:N-1
   if (k>0)
      C(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N)*sqrt(2);
   else
      C(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N);
   end   
end

out = (C')*in*C;

% ---------------------------------------------------------------------------------
% plot_bases - use the inverse DCT in 2 dimensions to plot the base pictures
%
% Note: we can get resolution be zero pading of the input matrix !!!
%       that is by calling: in = zeros(base_size*resolution)
%       where:  resolution is an integer > 1
%       So I will use zero pading for resolution (same as in the fourier theory)
%       instead of linear interpolation.
% ---------------------------------------------------------------------------------
function plot_bases( base_size,resolution,plot_type )

figure;
for k = 1:base_size
   for l = 1:base_size
      in = zeros(base_size*resolution);
      in(k,l) = 1;							% "ask" for the "base-harmonic (k,l)"
      subplot( base_size,base_size,(k-1)*base_size+l );
      switch lower(plot_type)
      case 'surf3d', surf( pdip_inv_dct2( in ) );
      case 'mesh3d', mesh( pdip_inv_dct2( in ) );
      case 'mesh2d', mesh( pdip_inv_dct2( in ) ); view(0,90);
      case 'gray2d', imshow( 256*pdip_inv_dct2( in ) );         
      end     
      axis off;
   end
end

% add a title to the figure
subplot(base_size,base_size,round(base_size/2));
h = title( 'Bases of the DCT transform (section 1.3)' );
set( h,'FontWeight','bold' );

% ---------------------------------------------------------------------------------
% image_8x8_block_dct - perform a block DCT for an image
% ---------------------------------------------------------------------------------
function transform_image = image_8x8_block_dct( input_image )

transform_image = zeros( size( input_image,1 ),size( input_image,2 ) );
for m = 0:15
    for n = 0:15
        transform_image( m*8+[1:8],n*8+[1:8] ) = ...
            pdip_dct2( input_image( m*8+[1:8],n*8+[1:8] ) );
    end
end


% ---------------------------------------------------------------------------------
% image_8x8_block_inv_dct - perform a block inverse DCT for an image
% ---------------------------------------------------------------------------------
function restored_image = image_8x8_block_inv_dct( transform_image )

restored_image = zeros( size( transform_image,1 ),size( transform_image,2 ) );
for m = 0:15
    for n = 0:15
        restored_image( m*8+[1:8],n*8+[1:8] ) = ...
            pdip_inv_dct2( transform_image( m*8+[1:8],n*8+[1:8] ) );
    end
end


% ---------------------------------------------------------------------------------
% calc_snr - calculates the snr of a figure being compressed
%
% assumption: SNR calculation is done in the following manner:
%             the deviation from the original image is considered 
%             to be the noise therefore:
%
%                   noise = original_image - compressed_image
%
%             the SNR is defined as:  
%
%                   SNR = energy_of_image/energy_of_noise
%
%             which yields: 
%
%                   SNR = energy_of_image/((original_image-compressed_image)^2)
% ---------------------------------------------------------------------------------
function SNR = calc_snr( original_image,noisy_image )

original_image_energy = sum( original_image(:).^2 );
noise_energy = sum( (original_image(:)-noisy_image(:)).^2 );
SNR = original_image_energy/noise_energy;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区三区四区五区| 日本一区二区久久| 成人性生交大合| 一个色综合av| 国产精品欧美极品| 欧美一二三在线| 欧美午夜不卡在线观看免费| 国产麻豆视频一区二区| 视频一区在线播放| 中文字幕在线观看不卡| 久久影院午夜论| 欧美丰满高潮xxxx喷水动漫| 97久久超碰国产精品电影| 狠狠色综合色综合网络| 视频一区二区中文字幕| 亚洲精品亚洲人成人网| 亚洲国产精品av| 精品国产一区二区三区av性色| 欧美性猛片aaaaaaa做受| av一区二区三区黑人| 韩国精品主播一区二区在线观看| 天堂影院一区二区| 亚洲激情自拍偷拍| 日韩伦理电影网| 国产精品久久久久9999吃药| 久久久无码精品亚洲日韩按摩| 欧美一级专区免费大片| 欧美日韩免费视频| 91黄色在线观看| 91啦中文在线观看| 91在线国内视频| 99国内精品久久| 不卡的电影网站| 成人福利在线看| 成人蜜臀av电影| thepron国产精品| av亚洲精华国产精华精华| 99久精品国产| 91免费观看国产| 色猫猫国产区一区二在线视频| 91麻豆福利精品推荐| 久久久综合视频| 精品剧情在线观看| 久久午夜国产精品| 久久男人中文字幕资源站| 国产亚洲成年网址在线观看| 久久欧美中文字幕| 国产精品区一区二区三区| 中文字幕在线一区二区三区| 国产日产亚洲精品系列| 亚洲国产精品国自产拍av| 亚洲欧美激情插| 亚洲国产一二三| 水野朝阳av一区二区三区| 久久福利资源站| 国内一区二区在线| 成人性视频免费网站| 色婷婷激情综合| 欧美日韩亚洲不卡| 日韩欧美色综合网站| 精品av久久707| 欧美激情一区二区在线| 亚洲欧美一区二区不卡| 亚洲v中文字幕| 国产自产高清不卡| 成人免费高清视频在线观看| 在线看国产一区| 欧美成人性福生活免费看| 久久久99久久精品欧美| 亚洲天堂福利av| 奇米色一区二区| 成人美女视频在线观看18| 欧美性色黄大片手机版| 精品美女一区二区三区| 国产精品激情偷乱一区二区∴| 一区二区高清免费观看影视大全| 青青草原综合久久大伊人精品优势| 国产精品白丝jk黑袜喷水| 在线视频国内一区二区| 日韩免费视频一区| 亚洲天堂成人在线观看| 久久国产人妖系列| 91香蕉视频mp4| 欧美电影免费观看完整版| 国产精品不卡一区| 日韩电影一区二区三区| 99国产一区二区三精品乱码| 日韩欧美激情一区| 亚洲男人天堂av| 国产高清精品网站| 在线不卡一区二区| 中文字幕在线不卡视频| 日韩电影在线免费看| 91亚洲精品久久久蜜桃| 精品乱人伦小说| 香港成人在线视频| va亚洲va日韩不卡在线观看| 欧美mv日韩mv亚洲| 亚洲激情综合网| 成人精品视频.| 欧美一卡在线观看| 亚洲一区国产视频| av亚洲精华国产精华精华| 精品国产乱码久久久久久牛牛 | 欧美日韩精品福利| 国产精品无圣光一区二区| 日韩av电影天堂| 99久久er热在这里只有精品66| 日韩欧美一级二级| 夜夜嗨av一区二区三区四季av| 国产成人免费网站| 日韩精品中午字幕| 日韩国产在线观看一区| 在线一区二区三区四区五区 | 中文字幕欧美激情一区| 六月婷婷色综合| 在线成人午夜影院| 亚洲一区二区在线观看视频| 成人性生交大片免费看在线播放| 日韩一区二区免费在线电影| 亚洲影院免费观看| 色素色在线综合| 亚洲色图色小说| 91视频精品在这里| 亚洲欧洲精品一区二区三区 | 成人高清免费观看| 国产片一区二区三区| 狠狠色综合日日| 久久众筹精品私拍模特| 九九精品视频在线看| 日韩精品一区国产麻豆| 热久久免费视频| 欧美一级搡bbbb搡bbbb| 三级成人在线视频| 欧美精品亚洲二区| 日韩和欧美的一区| 日韩亚洲欧美成人一区| 麻豆国产91在线播放| 久久一夜天堂av一区二区三区| 精品一区二区三区欧美| 久久久不卡影院| 成人av网站在线| 亚洲天堂精品视频| 欧美性受xxxx黑人xyx| 五月天丁香久久| 欧美一级生活片| 国产麻豆精品一区二区| 欧美国产激情一区二区三区蜜月| 成人性视频网站| 一区二区日韩av| 欧美男男青年gay1069videost| 天天影视涩香欲综合网| 欧美一区二区在线播放| 激情成人综合网| 中文字幕在线观看一区| 欧美影院午夜播放| 美日韩一区二区三区| 久久欧美一区二区| 99精品国产99久久久久久白柏| 亚洲激情综合网| 欧美不卡123| 99久久综合国产精品| 亚洲国产精品久久人人爱| 欧美一二三区在线| 成人精品视频一区二区三区尤物| 亚洲狠狠丁香婷婷综合久久久| 在线不卡一区二区| 国产99一区视频免费 | 日韩精品乱码免费| 久久蜜桃一区二区| 91福利精品第一导航| 久久成人羞羞网站| 亚洲色欲色欲www| 制服丝袜亚洲色图| 成人午夜看片网址| 亚洲成人tv网| 国产精品女人毛片| 欧美日韩www| 成人免费视频一区| 视频一区二区三区中文字幕| 久久久久9999亚洲精品| 欧美视频一区二区三区在线观看| 精一区二区三区| 亚洲一区二区综合| 日本一区二区三区免费乱视频| 欧美日韩视频不卡| 9色porny自拍视频一区二区| 日本女人一区二区三区| 亚洲女同一区二区| 久久午夜色播影院免费高清| 欧美日韩亚洲另类| 北条麻妃国产九九精品视频| 日本三级亚洲精品| 亚洲卡通动漫在线| 国产视频一区二区三区在线观看| 欧美日韩成人在线| 色综合天天狠狠| 国产成人av一区| 美国欧美日韩国产在线播放 | 韩国女主播成人在线|