RLEncode.m
资源名称:work.rar [点击查看]
上传用户:hwtw888
上传日期:2016-03-15
资源大小:177k
文件大小:1k
源码类别:
压缩解压
开发平台:
Matlab
- function [zipped, info] = RLEncode(vector)
- [m, n] = size(vector);
- %vector = vector(:)';
- vector = uint8(vector(:));
- L = length(vector);
- c = vector(1);
- e(1, 1) = c; %e(:, 1)存放灰度
- e(1, 2) = 0; %e(:, 2)存放行程
- t1 = 1;
- for j = 1: L
- if((vector(j) == c))
- e(t1, 2) = double(e(t1,2)) + 1;
- else
- c = vector(j);
- t1 = t1 + 1;
- e(t1, 1) = c;
- e(t1, 2) = 1;
- end
- end
- zipped = e;
- info.rows = m;
- info.cols = n;
- [m, n] = size(e);
- info.ratio = m*n/(info.rows * info.cols);