Archive for 'Linux/Unix'

VIM how to remove ^M at the end of lines

In unix the end of line is different than other systems. More times we edit windows files and when open in VI/VIM we see the ^M character at end of lines.
We can remove this characters with a simply search and replace of vim with this command:
:%s/^M//g
The ^M character is not valid write first ^ character [...]

Exuberant CTags and OpenCV with Vim. Thanks Piponazo!!

Piponazo have a wonderful spanish tutorial explianing how use Exuberant CTags in vim with a opencv as example and some tips for correct import ctags of opencv.
Exuberant Ctags tutorial. “La plaga Tux”

Thanks Piponazo.

The basics of background substraction

This tutorial explain the basics of background substraction. First of all we need define what is a background and what is a foreground.
We consider a background the pixels of image without motion. And a foreground the pixels with motion. Then the simplest background model assume each background pixel his brightness varies independently with normal distribution. [...]

GNUPLOT – 3d plot surface

For 3d plot gnuplot use command splot.
splot sin(sqrt((x*x+y*y)))/sqrt(x*x+y*y) t “weaves”
We can add the style pm3d to add a gradient surface texture
splot sin(sqrt((x*x+y*y)))/sqrt(x*x+y*y) with pm3d t “weaves”
But you can see we need more resolution, then we must set more isosamples:
set isosamples 75,75

For more info go to gnuplot page

AWK. Calculate mean, min and max

AWK is a general purpose programing language that is designed for processing text-based data. This unix command is very powerful and with it we can calculate the mean, min and max of a data stored in file.
data.txt:
10
20
50
100
200
500
awk command:
awk ‘{if(min==””){min=max=$1}; if($1>max) {max=$1}; if($1< min) {min=$1}; total+=$1; count+=1} END {print total/count, min, max}’ data.txt
Result:
146.667 10 500