MATLAB: Wcompress

image compressionMATLAB

Hi everybody, can someone please help me with this error, below is my code….
The CR_testImage.tif is unit8 59x64x3
X = imread('CR_testImage.tif');
[CR,BPP] = wcompress('c',X,'w_test.wtc','spiht','maxloop',12);
Xc = wcompress('u','w_test.wtc');
subplot(1,2,1); image(X);
axis square;
title('Original Image')
subplot(1,2,2); image(Xc);
axis square;
title('Compressed Image - 12 steps - bior4.4')
delete('w_test.wtc')
*When I run this code the message show..
??? Subscript indices must either be real positive integers or logicals.
Error in ==> wtc_spiht>wtc_spiht_dec at 524
Signific_MAT(idx_CHILD+d_PIX_Plan) = ...
Error in ==> wtc_spiht at 23
case 2 , [varargout{1:nbout}] = wtc_spiht_dec(varargin{:});
Error in ==> wtcmngr at 98
[varargout{1:nbout}] = funHDL('dec',WTC_Struct,stepFLAG);
Error in ==> wcompress at 452
X_decoded = wtcmngr('read',inputFile,stepFLAG);
Error in ==> Test_wc6 at 11
Xc = wcompress('u','w_test.wtc');
Thank you in advance..
Warin

Best Answer

You need to extend the one dimension of your image to the next power of 2 - 64x64x3, you can pad with zeros, see wextend() for help, then the above will work.
For example:
X = randi([0 255],64,64,3,'uint8');