I have Matlab code for run length encoding and I want to make code for decoding. Please can anyone help me in making the decoder for this code?
The encoder is as the following:
function out = rle (image)
%
% RLE(IMAGE) produces a vector containing the run-length encoding of
% IMAGE, which should be a binary image. The image is set out as a long
% row, and the conde contains the number of zeros, followed by the number
% of ones, alternating.
%
% Example:
%
% rle([1 1 1 0 0;0 0 1 1 1;1 1 0 0 0])
%
% ans =
%
% 03453
%
level = graythresh(image);
BW = im2bw(image, level);
L = prod(size(BW));
im = reshape(BW.', 1, L);
x = 1;
out = [];
while L ~= 0,
temp = min(find(im == x));
if isempty(temp)
out = [out, L];
break;
end
out = [out, temp-1];
x = 1 - x;
im = im(temp : L);
L = L - temp + 1;
end
end