Converting STL surface mesh to volume mesh using GMSH
Just three simple steps:
> File -> Merge -> “filename.stl”
> Geometry -> Elementary entities -> Add -> New -> Volume, click on the surface to build the volume
> Mesh -> 3D
Sample STL file can be downloaded @ https://geuz.org/trac/gmsh/attachment/wiki/STLRemeshing/pelvis.stl.gz
If some errors happened, it is the problem of your input stl surface mesh. One common error is “self intersecting surface mesh, computing interesections (this could tak a while)”. If your surface is generated by some segmentation software and too complicated to fix. You may want to convert your surface mesh to a solid volume and then rebuild the surface mesh through isosurface reconstruction.
—————————–
http://www.geuz.org/pipermail/gmsh/2010/005558.html
install Fedora 16 from Ubuntu, network installation
I just switched to Fedora from Ubuntu. This time the installation is fairly easy. First, I copied vmlinuz and initrd.img from the isolinux folder of the Fedora installation CD to /boot, and then I rebooted the system to enter the grub command line. And typed:
grub> linux /vmlinuz
grub> initrd /initrd.img
grub> boot
then the Fedora installation begun. Later on you just need to choose network interface for installation. The whole installation lasted less than one hour in my case.
—-
You might meet the login problems, “Oh! No! Something has gone wrong. A problem has occured and the system can’t recover. Please contact a system adminstrator”, which could be solved by:
yum remove selinux-policy selinux-policy-targeted
yum update libsepol
yum --nogpgcheck install libsepol http://kojipkgs.fedoraproject.org/
packages/selinux-policy/3.10.0/55.fc16/noarch/
selinux-policy-3.10.0-55.fc16.noarch.rpm --enablerepo=u*g
yum --nogpgcheck install http://kojipkgs.fedoraproject.org/packages/
selinux-policy/3.10.0/55.fc16/noarch/
selinux-policy-targeted-3.10.0-55.fc16.noarch.rpm --enablerepo=u*g
http://fedoraforum.org/forum/showthread.php?t=271999&page=2
Kile on Windows
Installing Kile on Windows now is very simple, thanks to the effort of Windows KDE team. You just need to select Kile when you install Windows KDE packages. Detailed manual could be found at http://sourceforge.net/apps/mediawiki/kile/index.php?title=KileOnWindows
Please remember to install a Latex distribution, i.e., miktex or texlive, before installing kile. I personally like texlive better, simply because dviout integrated in texlive loads dvi files much faster than YAP.
—————————————————————————————————————
dviout tmpps1.pbm problem
Sometimes dviout maybe not responding and you have the message “gswin32.exe is making tmpps1.pbm” from the program status bar. This is an old problem with dviout windows. As long as the package ‘hyperref’ is used in your tex file, you would have this problem.
tsearchn and pointLocation
To use pointLocation() to find the enclosing simplex (triangle/tetrahedron) for each query point location in Matlab, one has to supply this function with a ‘DelaunayTri’ structure as an input. This is a newly introduced class for performing delaunay triangulation. While in my case I need to reuse my saved delaunay triangulation results and assigned it to the Triangulation component of the ‘DelaunayTri’ structure. However I got this error,
??? Error using ==> subsasgn
Cannot assign values to the Triangulation.
I think this is because Triangulation is a private member of the class DelaunayTri, and every time one revises the values of X, this Triangulation is updated automatically. If you are still allowed, you can use the old function ‘tsearchn’ to find the enclosing simplex of the delaunay triangulation. It is also very easy to write a simple function to compute the barycentric coordinate for each query point location. In case ‘tsearchn’ is not supported by the future Matlab, you can also write your own version of ‘tsearchn’. The brute force way is to check the barycentric coordinate of that point for each triangle. If one of the coordinates is negative, then the point is outside of that triangle.
long equation in two column document
We can embed the long equation into a floating figure. This works for IEEE conference/journal submissions.
\begin{figure*}[!t]
\normalsize
\begin{equation}
….
\end{equation}
\hrulefill
\vspace*{4pt}
\end{figure*}
Two video clips side by side using imagemagick and ffmpeg
Just copy the following code into a script file and run it at your bash. Please remmeber to “d2u your_file_name” otherwise you would have the error “syntax error near unexpected token $’\r’ “.
—————————————————————————————————-
n=900 #image number
for(( i=0; i<n; i++))
do
montage -label ‘%f’ “xrCor$(printf “%04d” $i).png” “xrSag$(printf “%04d” $i).png” -tile x1 -geometry +4+4 “montage$(printf “%04d” $i).bmp”
done
ffmpeg -b 7000k -r 10 -i montage%04d.bmp -b 7000k -r 10 -vcodec mpeg4 -vtag DIVX montage.avi
draw line segments in matlab
After spending some effort searching online, I found one solution:
r = 5;
x1 = linspace(pos.cx – r, pos.cx + r);
y1 = linspace(pos.cy, pos.cy);
x2 = linspace(pos.cx, pos.cx);
y2 = linspace(pos.cy – r, pos.cy + r);
index1 = sub2ind(size(im), round(y1), round(x1));
index2 = sub2ind(size(im), round(y2), round(x2));
im(index1) = 127; % set the valudes to 127 for display
im(index2) = 127; % set the valudes to 127 for display
The above code snippet is used to draw a cross on an image or matrix. Because of over sampling, the line drawn is without aliasing artifacts. For drawing lines on figures, there exists an easier solution, just use function ‘line’. For example:
line(rect(1,:), rect(2,:),’Color’,'r’,'LineWidth’,2);
Reduce PDF size generated by Latex
One of the problems we often meet when submitting papers is that the size of our pdf paper is beyond the space limit. For graphics and vision conferences, it is very common for us to generate a ~50 MB pdf while the size limit for the paper and supplemental materials together is about 20MB. That is necessary for the conference to guarantee its submission site is still functionable at the last seconds before the deadline.
To reduce the pdf size, you could reduce your eps/png figures manually before you include them into your tex file. There is also a very easy way if you have Adobe acrobat. You could use “Advanced->PDF Optimizer”. In the opened dialog, you can set the compression of figures, fonts, and other staff to reduce your pdf size. I just managed to reduce the size of my paper from 20MB to about 400KB.
An alternative way is to use PrimoPDF. It has several predefined settings for generating PDF best for screen, ebook, print, and prepress. It also supports customized settings.
If you already have an eps file, and still want to reduce its size. You could run the following code: (http://electron.mit.edu/~gsteele/pdf/)
> gs -r300 -dEPSCrop -dTextAlphaBits=4 -sDEVICE=png16m -sOutputFile=fig.png -dBATCH -dNOPAUSE fig.eps
> convert -quality 80 fig.png fig.jpg
> convert fig.png eps3:fig.eps
Instead of using LaTex, you could also use PDFLaTex. In this case, you can use the following code to convert your figures to PDF files.
> for i in *eps; do ps2pdf -DEPSCrop $i; done
> sed -i ‘s/\.eps}/}/g’ *tex
Forming a 2D window from a 1D Function
I came to this question because of the Kaiser window used for my BM3D implementation. I used Matlab to generate the Kaiser window I want for my C code so I don’t bother to write that function in my project. However, Matlab only has 1D version of the window functions. The following demonstrates two ways to generate the 2D window from its 1D function.
——————————————————————-
There are basically two ways of forming a 2D window from a 1D function. The
first is the outer product formulation; the second is the rotational
formulation. To create a outer product window (which your kaiser examples
look like they are trying to do), you can use
w1D = hamming(16); % Some 1D window
w2D = w1D(:) * w1D(:).’; % Outer product
To use a rotational formulation (which generally gives more circular
contours), you can use
L = 16;
w1D = hamming(L); % Some 1D window
M = (L-1)/2;
xx = linspace(-M,M,L);
[x,y] = meshgrid(xx);
r = sqrt( x.^2 + y.^2 );
w2D = zeros(L);
w2D(r<=M) = interp1(xx,w1D,r(r<=M));
http://www.mathworks.com/matlabcentral/newsreader/view_thread/23588
Using opencv from python on windows
http://stackoverflow.com/questions/4709301/installing-opencv-on-windows-7-for-python-2-7
The official OpenCV2.2 installer does not install the Python bindings into your Python directory. There should be a Python2.7 directory inside your OpenCV 2.2.0 installation directory. Copy the whole Lib folder from OpenCV\Python2.7\ to C:\Python27\. Then set the windows environmental variable PATH to include your OpenCV\bin directory together with C:\Python.
Alternatively use the opencv-python installers at http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv.