KDOXG

compc_cpc

Dec 7th, 2020 (edited)
728
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function PSNR = compc_cpc(imagem, tx)
  2.   Im = imread(imagem);
  3.  
  4.   #imwrite(Im,"img.jp2","CompressionRatio",tx);
  5.   imwrite(Im,"img.jp2");
  6.  
  7.   Im_c = imread("img.jp2");
  8.   imshow(Im_c);
  9.  
  10.   memsize = numel(Im);
  11.   disk_size = imfinfo("img.jp2").FileSize;
  12.   taxa_comp = memsize / disk_size;
  13.  
  14.   if length(size(Im)) == 3
  15.     Im = rgb2ycbcr(Im);
  16.     Im_c = rgb2ycbcr(Im_c);
  17.     Im = Im(:,:,1);
  18.     Im_c = Im_c(:,:,1);
  19.   endif
  20.  
  21.   MSE = sum(sum((Im .- Im_c).^2)) / (rows(Im) * columns(Im));
  22.   if MSE == 0
  23.     PSNR = inf
  24.   else
  25.     PSNR = 10 * log10((2^8 - 1)^2/MSE);
  26.   endif
  27. endfunction
  28.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×