Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Implementation Run Length Smoothing Algorithm in C++

Hi, I am new with C++ and OpenCV.

I came across an interesting article:

http://crblpocr.blogspot.fr/2007/06/run-length-smoothing-algorithm-rlsa.html http://crblpocr.blogspot.fr/2007/06/determination-of-run-length-smoothing.html

There is RLSA implementation in Matlab by this thread :

http://mathworks.cn/matlabcentral/newsreader/view_thread/318198

I wonder if anyone has ever encountered RLSA implement in C++??

Thank

Implementation Run Length Smoothing Algorithm in C++

Hi, I am new with C++ and OpenCV.

I came across an interesting article:

http://crblpocr.blogspot.fr/2007/06/run-length-smoothing-algorithm-rlsa.html http://crblpocr.blogspot.fr/2007/06/determination-of-run-length-smoothing.html

There is RLSA implementation in Matlab by this thread :

http://mathworks.cn/matlabcentral/newsreader/view_thread/318198

I wonder In link above : Matlab Code Vector Version by Bruno Luong

% Data
x=[0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0;
  0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0]
C = 4;
% Engine
[m n] = size(x);
xx = [ones(m,1) x ones(m,1)];
xx = reshape(xx',1,[]);
d = diff(xx);
start = find(d==-1);
stop = find(d==1);
lgt = stop-start;
b = lgt <= C;
d(start(b)) = 0;
d(stop(b)) = 0;
yy = cumsum([1 d]);
yy = reshape(yy, [], m)';
y = yy(:,2:end-1)

Normal Version by Yumnam Kirani Singh

clear;clc;
x=imread('Picture.jpg');
y=rgb2gray(x) ;
z=histeq(y);
t=im2bw(z);
u=double(t);
[a b]=size(u);
for i=1:a
    c=1;
for j=1:b
   if anyone u(i,j)==1
if (j-c)<=5 
    u(i,c:j)=1;
end
c=j;
 end
 end
if (b-c)<=5
   u(i,c:b)=1;
end
end
imshow(u,[]);

Anyone has ever encountered RLSA experience in C++ could implement in C++??

it with OpenCV, C++ using Mat Structure??

Thank

Implementation Run Length Smoothing Algorithm in C++

I am new with C++ and OpenCV.

I came across an interesting article:

http://crblpocr.blogspot.fr/2007/06/run-length-smoothing-algorithm-rlsa.html http://crblpocr.blogspot.fr/2007/06/determination-of-run-length-smoothing.html

There is RLSA implementation in Matlab by this thread :

http://mathworks.cn/matlabcentral/newsreader/view_thread/318198

In link above : Matlab Code Vector Version by Bruno Luong

% Data
x=[0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0;
  0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0]
C = 4;
% Engine
[m n] = size(x);
xx = [ones(m,1) x ones(m,1)];
xx = reshape(xx',1,[]);
d = diff(xx);
start = find(d==-1);
stop = find(d==1);
lgt = stop-start;
b = lgt <= C;
d(start(b)) = 0;
d(stop(b)) = 0;
yy = cumsum([1 d]);
yy = reshape(yy, [], m)';
y = yy(:,2:end-1)

Normal Version by Yumnam Kirani Singh

clear;clc;
x=imread('Picture.jpg');
y=rgb2gray(x) ;
z=histeq(y);
t=im2bw(z);
u=double(t);
[a b]=size(u);
for i=1:a
    c=1;
for j=1:b
   if u(i,j)==1
if (j-c)<=5 
    u(i,c:j)=1;
end
c=j;
 end
 end
if (b-c)<=5
   u(i,c:b)=1;
end
end
imshow(u,[]);

Anyone has experience in C++ could implement it with OpenCV, C++ using Mat Structure??

Thank