how to get the compressed file size of image compressed by wavelet based compression

1 view (last 30 days)
I am using wavelet function wdencmp to compress dicom image I use the following fuction but the problem is I want to write the compressed file before the reconstruction of the compressed image the function is as the following
function [out] = wav (infile,nx,wx,outfile)
%Example wav ('Brain.dcm',2,'sym3','Recostructed Image.dcm')
a=dicomread(infile);
a=mat2gray(a);
figure('Name','Input image');
imshow(a);
n=nx; % Decomposition level
w = wx; % Name of the wavelet
[c l] = wavedec2(a,n,w); % Multilevel 2-D wavelet decomposition.
opt = 'gbl'; % Global threshold
thr = 80; % Threshold
sorh = 's'; % soft thresholding
keepapp = 1; % Approximation coefficients cannot be thresholded
[xd,cxd,lxd,perf0,perfl2] = wdencmp(opt,c,l,w,n,thr,sorh,keepapp);
disp('Compression Ratio');
disp(perf0)
figure('Name','Compressed Image');
imshow(xd);
% Decompression
R = waverec2(c,l,w);
R=mat2gray(R);
rc = double(R);
figure('Name','Reconstructed Image');
imshow(rc);
dicomwrite(rc,outfile);

Answers (1)

Walter Roberson
Walter Roberson on 10 Jul 2017
  3 Comments
Walter Roberson
Walter Roberson on 11 Jul 2017
So identify the variables that need to be written out, and write them to disk in an efficient way: arithmetic coding or huffman coding . Or if your actual information content of your arrays aligns nicely with byte boundaries, then fwrite() directly or after blocking from whatever internal representation you are using into bytes (e.g., if you have an array of single precision values that has only 24 useful bits per word, then convert that to a series of 3 bytes in a reversible way.)

Sign in to comment.

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!