Skip to main content

Posts

Showing posts with the label Block Trunction Coding - Image Compression

Absolute Moment Block Truncation Coding (AMBTC)- MATLAB Code

Here is the matlab code.. Cheers !! %AMBTC %Ref:Lema, M., and O. Mitchell. %”Absolute moment block truncation coding and its application to color images.” % IEEE Transactions on communications 32.10 (1984): 1148-1157. %Programmed By: Sankarasrinivasan S %Multimedia Signal Processing Lab, Dept. of Elec Engg. NTUST %Oct 2016 function [H]=ambtc(in,bs) %in–> input image; bs–> blocksize [s1 s2]=size(in); n=bs*bs; for i=1:bs:s1 for j=1:bs:s2 bl=in(i:i+(bs-1),j:j+(bs-1)); mn=mean(mean(bl)) ; %Computing Mean fm=mean(mean(abs(bl-mn))) ; %Abs moment g=(n*fm)/2; c=bl>mn; q=nnz(c); if(q==n) b=mn; a=0; else b=mn+(g/q); a=mn-(g/(n-q)); end out=round(c.*b+(~c).*a); H(i:i+(bs-1),j:j+(bs-1))=out; end end %To Validate Paper Results % test=[121 114 56 47; 37 200 247 255; 16 0 12 169; 43 5 7 251;]; % mn = % 98.7500 % fm = % 83.2188 % g = % 665.7500 % b = % 193.8571 % H = % 194 194 25 25 % 25 194 194 194 % 25 25 25 194 % 25 25 25 194

Block Truncation Coding (BTC)– Image Compression- MATLAB

Block Truncation Coding (BTC): To my knowledge, BTC is the simplest approach to perform image compression. BTC- Implementation: As provided in its title, BTC perform compression in a block wise manner. Referring to the figure, each block is MxN size, then for each block mean, a and b are computed (please check the paper to find out the formula for 'a' and 'b') To perform compression, each pixel in the block is thresholded with the block mean value IF            the pixel > mean, then it is assigned 1 ELSE      the pixel is assigned 0 This output is termed as the bitmap image. While transmitting, the bit map image along with it 'a' and 'b' are transmitted. If suppose the block size is 8x8, and for a typical 8-bit image Original image = 8x8x8= 512 bits BTC image: Bitmap=8x8x1=64 bits                      'a' and 'b'= 16 bits         ...