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.

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.
<<
>>

 채택된 답변

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

thanks a lot ....!!....:) Debarpita Chaudhuri.
Sir I tried to get these images without plotting, but my program output is only giving the the quantized image of the lowpass Approximation of the non-ROI. However I am not getting the lowpass approximation and verticle detail image of the non-ROI. MY code is given below. Also Sir how do I define my quantizer, kindly help.
if true
% f = imread('Image_difference.bmp');
imshow(f)
wname = 'sym4';
[CA,CH,CV,CD] = dwt2( f, wname, 'mode', 'per');
imagesc(CV); title('Vertical Detail Image');
colormap gray;
imagesc(CA); title('Lowpass Approximation');
q = quantizer;
y1 = quantize(q, CA);
y2 = quantize(q, CH);
y3 = quantize(q, CV);
y4 = quantize(q, CD);
imagesc(y1); title('quantize lowpass Approximat
end
Sir, kindly clarify my doubts. The image of the quantized non-ROI is enclosed herewith. thanks and regards Debarpita Chaudhuri.
Sir , I am getting the images now by writing figure in front of imagesc. but now these are colored images. Are they correct?....and kindly help to define the quantizer. My code is given herewith.
if true
% f = imread('Image_difference.bmp');
imshow(f)
wname = 'sym4';
[CA,CH,CV,CD] = dwt2( f, wname, 'mode', 'per');
figure, imagesc(CV); title('Vertical Detail Image');
colormap gray;
figure, imagesc(CA); title('Lowpass Approximation');
q = quantizer;
y1 = quantize(q, CA);
y2 = quantize(q, CH);
y3 = quantize(q, CV);
y4 = quantize(q, CD);
figure, imagesc(y1); title('quantize lowpass Approximation');
end
kindly help Sir. thanks and regards Debarpita Chaudhuri.
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.
@Debarpita Chaudhuri what was your solution, and were you able ot achieve compression using this ?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numeric Types에 대해 자세히 알아보기

질문:

2016년 6월 14일

댓글:

2023년 9월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by