inv_rle

PURPOSE ^

The string returned by rle2 always ends with 0, so that it is

SYNOPSIS ^

function [ristra_original] = inv_rle(ristra)

DESCRIPTION ^

 The string returned by rle2 always ends with 0, so that it is
 to find the last 0 of the string and take the following values ​​(which will
 be the number of consecutive zeros to replace each 0 appears
 previously).

 When all have been replaced it takes the last zero again,
 removing the previously processed block and so on to the beginning.

 The blocks processed rle2 lack the DC component, it
 will be get from the DPCM errors.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %
0002 % The string returned by rle2 always ends with 0, so that it is
0003 % to find the last 0 of the string and take the following values ​​(which will
0004 % be the number of consecutive zeros to replace each 0 appears
0005 % previously).
0006 %
0007 % When all have been replaced it takes the last zero again,
0008 % removing the previously processed block and so on to the beginning.
0009 %
0010 % The blocks processed rle2 lack the DC component, it
0011 % will be get from the DPCM errors.
0012 %
0013 
0014 function [ristra_original] = inv_rle(ristra)
0015 ristra_original = zeros(256,255);
0016 pos_ceros = find(ristra == 0);
0017 tamanyo = length(ristra);
0018 for i = 256:-1:1
0019       if(i == 10)
0020           a = 1;
0021       end
0022     bloque = [];
0023 
0024     pos_ult_cero = pos_ceros(end);
0025 
0026     num_ceros = ristra(pos_ult_cero + 1:tamanyo);
0027 
0028     ristra = ristra(1:pos_ult_cero);
0029 
0030     tamanyo = length(ristra);
0031 
0032     for j = 1:length(num_ceros)
0033 
0034         pos_ceros = pos_ceros(1:end-1);
0035 
0036         bloque = [zeros(1,num_ceros(end)) bloque];
0037 
0038         if(length(num_ceros) > 1)
0039             num_ceros = num_ceros(1:end-1);
0040         end
0041 
0042         ristra = ristra(1:tamanyo-1);
0043 
0044         tamanyo = length(ristra);
0045 
0046         if(length(bloque) == 255)
0047             break;
0048         end
0049 
0050         if(tamanyo == 0)
0051             break;
0052         end
0053 
0054         while(ristra(tamanyo) ~= 0 & length(bloque) < 255)
0055             bloque = [ristra(tamanyo) bloque];
0056             ristra = ristra(1:tamanyo-1);
0057             tamanyo = length(ristra);
0058             if(tamanyo == 0)
0059                 break;
0060             end
0061         end
0062     end
0063 
0064     ristra_original(i,:) = bloque;
0065 end

Generated on Fri 07-Mar-2014 13:29:20 by m2html © 2005