Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PSNR = compc_cpc(imagem, tx)
- Im = imread(imagem);
- #imwrite(Im,"img.jp2","CompressionRatio",tx);
- imwrite(Im,"img.jp2");
- Im_c = imread("img.jp2");
- imshow(Im_c);
- memsize = numel(Im);
- disk_size = imfinfo("img.jp2").FileSize;
- taxa_comp = memsize / disk_size;
- if length(size(Im)) == 3
- Im = rgb2ycbcr(Im);
- Im_c = rgb2ycbcr(Im_c);
- Im = Im(:,:,1);
- Im_c = Im_c(:,:,1);
- endif
- MSE = sum(sum((Im .- Im_c).^2)) / (rows(Im) * columns(Im));
- if MSE == 0
- PSNR = inf
- else
- PSNR = 10 * log10((2^8 - 1)^2/MSE);
- endif
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement