Today, when I use the toolbox for calibration, it gives a error :
"
??? Error using ==> eq
Matrix dimensions must agree.
Error in ==> loadpgm at 68
elseif ~any(c == white)
"
The images is PGM format. These errors come from "loadpgm.m" file. I find that when the error happens, the c is empty, which means the reader pointer is getting the end of file.
In the "loadpgm.m" file, the program likes:
"
maxval = fscanf(fid, '%d', 1);
while 1
c = fread(fid,1,'char');
if c == '#',
fgetl(fid);
elseif ~any(c == white)
fseek(fid, -1, 'cof'); % unputc()
break;
end
end
"
The program read maxval correctly, so it is going on and checking next value, if it's '#' or says 35, then the program will read a row line. What happens here, the interesting thing is the first image data value is 35, which is not '#', but just a interger value 35. The program "think" it's '#', and get the whole line which contain all image data, so next time ,it finds it goes to end of file.
I change the first image data to 36, then it works very well. The matlab function imread works well here for this special case.
Monday, March 15, 2010
Wednesday, March 3, 2010
The errors and solutions when compiling the levmar with lapack
Well, there are a lot of errors. I google a lot to find solutions, and I add them here. Good for newbies.
Q1. undefined reference to `MAIN__'
S: add '-u MAIN_' in the GCC part of Makefile
Q2. undefined symbol: _gfortran_concat_string
S: add '-gfortran' in the GCC part of Makefile
Q3. misuse the command matlab mex with the command mex from pdfTeXK.
S: replace 'mex' by whole directory '/where your matlab is/bin/mex' in Makefile
Q4. multiple definition of `xerbla_'
S: set 'LAPACKBLASLIBS_PATH=/usr/lib/atlas' in the Makefile of matlab subfolder
Q1. undefined reference to `MAIN__'
S: add '-u MAIN_' in the GCC part of Makefile
Q2. undefined symbol: _gfortran_concat_string
S: add '-gfortran' in the GCC part of Makefile
Q3. misuse the command matlab mex with the command mex from pdfTeXK.
S: replace 'mex' by whole directory '/where your matlab is/bin/mex' in Makefile
Q4. multiple definition of `xerbla_'
S: set 'LAPACKBLASLIBS_PATH=/usr/lib/atlas' in the Makefile of matlab subfolder
conflict command in linux: matlab mex with mex from pdflatex
In the Ubuntu, two commands have same name. The way to solve this problem is to use command name with whole directory, e.g, /opt/matlab/bin/mex. You can use this whole name instead of short name "mex" in the Makefile.
Thursday, January 14, 2010
Linux Matlab and German keyboard
The new linux version matlab (e.g. R2008, R2009) can not work with german keyboard, it works following the english keyboard map.
I have tried a lot method and it still can not work until today (great day)!
When I run matlab, it show me a error message:
"
********************************libjvm.so
[0xb31ab8ec]
Locking assertion failure. Backtrace:"
It can not lock the java. The reason is it find the wrong one. The solution is run a command shell and type:
"export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.17/jre
"
Now it correctly show the character of the german keyboard. Of course, you may have different version of JAVA and install directory that you must figure out, and use yours instead mine. You also can add this command to your "~/.bashrc" file, so that every time you login, you donot have to run this command manually.
But the symbols "^" and "~" still can not work in this Linux. I test this method on Windows Vista, both symbols can work.
On Vista, open a command prompt, then use command setx to set the variable MATLAB_JAVA:
"setx "MATLAB_JAVA" "C:\*************""
I have tried a lot method and it still can not work until today (great day)!
When I run matlab, it show me a error message:
"
********************************libjvm.so
[0xb31ab8ec]
Locking assertion failure. Backtrace:"
It can not lock the java. The reason is it find the wrong one. The solution is run a command shell and type:
"export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.17/jre
"
Now it correctly show the character of the german keyboard. Of course, you may have different version of JAVA and install directory that you must figure out, and use yours instead mine. You also can add this command to your "~/.bashrc" file, so that every time you login, you donot have to run this command manually.
But the symbols "^" and "~" still can not work in this Linux. I test this method on Windows Vista, both symbols can work.
On Vista, open a command prompt, then use command setx to set the variable MATLAB_JAVA:
"setx "MATLAB_JAVA" "C:\*************""
Tuesday, January 5, 2010
Gradient of image and hough transform
直线参数表达式:rho=x*cos(theta)+y*sin(theta);
rho 是 从原点到直线的法线垂直距离。theta 是该法线和X轴正向夹角。所以利用HOUGH TRANSFORM的时候,要注意,theta不是直线的倾斜角或者它的正切不是切向量,而是法向量。设直线斜率是K=-1/tan(theta);
rho 是 从原点到直线的法线垂直距离。theta 是该法线和X轴正向夹角。所以利用HOUGH TRANSFORM的时候,要注意,theta不是直线的倾斜角或者它的正切不是切向量,而是法向量。设直线斜率是K=-1/tan(theta);
Thursday, December 10, 2009
How to print nice figure on matlab
Here is an example that can print current figure to a eps file with DPI=300 .
figure;
print(gcf, '-depsc','-r300', figname);
"gcf" means the current figure. "-depsc" means save as eps color image. "-r300" means 300dpi, "figname" should be something like "name.eps"
figure;
print(gcf, '-depsc','-r300', figname);
"gcf" means the current figure. "-depsc" means save as eps color image. "-r300" means 300dpi, "figname" should be something like "name.eps"
Monday, December 7, 2009
Mimimum distance from point to a curve
1. Assume we already know the function of curve: y=f(x); Given a point p(x1,y1), calculate the minimum distance:
D=sqrt((x-x1)^2+(y-y1)^2);
D*=(x-x1)^2+(y-y1)^2;
substitute y by f(x);
D*=(x-x1)^2+(f(x)-y1)^2;
Compute the derivative of D* and set it to zero: D*'=0, then we can solve x; substitute x , we get minimum distance D*;
2. The other one is no function expression of curve. We need calculate all points.
D=sqrt((x-x1)^2+(y-y1)^2);
D*=(x-x1)^2+(y-y1)^2;
substitute y by f(x);
D*=(x-x1)^2+(f(x)-y1)^2;
Compute the derivative of D* and set it to zero: D*'=0, then we can solve x; substitute x , we get minimum distance D*;
2. The other one is no function expression of curve. We need calculate all points.
Subscribe to:
Posts (Atom)