Effacer les filtres
Effacer les filtres

I am trying to do DWT transform on image and then quantize the image for lossy compression. However I am not getting any image after quantization, only a plotting of the signals are obtained. Kindly help.

3 vues (au cours des 30 derniers jours)
Sir , I am doing a region of interest (ROI) based compression on medical images. I am doing DWT and quantization on Non-ROI or the background. However I am not getting any image after quantization. I need the quantized image. My code is given below.
if true
% f = imread('Image_difference.bmp');
imshow(f)
wname = 'sym4';
[CA,CH,CV,CD] = dwt2( f, wname, 'mode', 'per');
subplot(311)
imagesc(CV); title('Vertical Detail Image');
colormap gray;
subplot(312)
imagesc(CA); title('Lowpass Approximation');
q = quantizer;
y1 = quantize(q, CA);
y2 = quantize(q, CH);
y3 = quantize(q, CV);
y4 = quantize(q, CD);
subplot(313)
plot(CA, y1); title('quantize lowpass Approximation');
end
Sir I am also sending the images herewith.
Kindly help me Sir. Thanks and regards Debarpita Chaudhuri.
<<
>>

Réponse acceptée

Sachin Shrestha
Sachin Shrestha le 14 Juin 2016
Hi Debarpita,
There are some issues with the code. The major one being the last line;
plot(CA, y1);
Try this instead to get the image, imagesc(y1);
alike the previous ways to display the image. I can't understand why you are plotting those values to get the image.
You may define the 'quantizer' to get the better results.
I hope this will help. Good Luck!
  5 commentaires
Debarpita Chaudhuri
Debarpita Chaudhuri le 21 Juil 2016
Sir, I want to apply arithmetic coding on the quantized output...I have a code but dont know how to make it work ...kindly help Sir. The code for arithmetic coding is given below.
if true
% %%ARITHMETIC CODING USING THE INCREMENTAL ENCODING TECHNIQUE.
function[Tag_bits]=Arithmetic_enc(sym,p,seq) tic; % TIC-TOC commands are used to measure the simulation time of the program. format long g; %% ARGUMENTS OF THE FUNCTION % SYM is a string of symbols of information from the source. % P represents the array of Probabilities of the corresponding symbols in % the SYM string. % SEQ is the string of sequence of symbols to be encoded by arithmetic % coding.
if(length(sym)==length(p) && sum(p)==1) %% ALGORITHM IMPLEMENTATION
% Calculate the Symbol Intervals.
Fx=zeros(1,length(sym));
for i=1:length(sym)
if i==1
Fx(i)=p(i);
else
Fx(i)=Fx(i-1)+p(i);
end
end
% Encoding the Sequence of Symbols.
L=0;U=1; % Initial Lower and Upper Intervals.
Tag_bits=zeros(1,0); % Initializing the Tag Bits.
for i=1:length(seq)
j=find(seq(i)==sym); % Finds the Index of the sequence symbol in the symbol string.
if(j==1)
L_new=L;
else
L_new=L+(U-L)*Fx(j-1);
end
U_new=L+(U-L)*Fx(j);
L=L_new;
U=U_new;
while((L<0.5 && U<0.5) ||(L>=0.5 && U>0.5))
if(L<0.5 && U<0.5)
Tag_bits=[Tag_bits,'0'];
L=2*L;
U=2*U;
else
Tag_bits=[Tag_bits,'1'];
L=2*(L-0.5);
U=2*(U-0.5);
end
end
end
tag=(L+U)/2;
% Embedding the Final Tag Value.
bits=zeros(1,0);
if(2*tag>1)
tag=2*tag-1;
bits=[bits,'1'];
else
tag=2*tag;
bits=[bits,'0'];
end
while(bin2dec(bits)/2^length(bits)<L)
if(2*tag>1)
tag=2*tag-1;
bits=[bits,'1'];
else
tag=2*tag;
bits=[bits,'0'];
end
end
Tag_bits=[Tag_bits,bits];
% Padding of zeros is done to keep the TAG BITS size multiple of 16 bits.
Tag_bits=[Tag_bits,dec2bin(0,16-rem(length(Tag_bits),16))];
display('Tag Value is:');
disp(bin2dec(Tag_bits)/2^length(Tag_bits));
display('Tag Word is:');
Tag_bits=[Tag_bits,dec2bin(length(seq),16)];
else
display('Plese enter proper values!!!');
end
toc;
end
Sir I cant understand what should I put for sym, p and seq as the input. Sir please help.
enyawson
enyawson le 19 Sep 2023
@Debarpita Chaudhuri what was your solution, and were you able ot achieve compression using this ?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by