Category Archives: Techniques

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.

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

RAW vs TIFF

Need to read raw images for my project. I found lots of open source packages on line, but it still needs many efforts to read and incorporate the code. Then I remember that TIFF has 16 bit version, maybe I could convert raw to 16bit tiff, which could still give me enough information about the scene, since normally raw images have 12 or 14 bits for each pixel. This sounds convenient and effortless. However, after a few experiments, I found that 16 bit tiff still loses lots of information about the scene. Mainly because when you convert raw to tiff, you have to do demosaicing, white balancing, sharpening and gamma correction for viewing (maybe). This process will inevitably truncate some head room gained by using raw format when comparing with jpeg. That is why people says “stay in Lightroom for as long as you can” (or the equivalent “do as much in ACR as you can)”), as all edits in Lightroom are nondestructive and non-cumulative.

For a detailed investigation, please check out these posts,
http://forums.adobe.com/message/2742439
http://www.bobatkins.com/photography/digital/raw.html
http://www.cambridgeincolour.com/tutorials/RAW-file-format.htm
http://osp.wikidot.com/raw

content management system

Long time ago, I tried to set up a blog website on my desktop, since I have static IP at school. Now this could be done very easily by some content management systems. The three most popular CMS are wordpress, drupal, and joomla. Drupal is developer friendly, and hard to setup. WordPress is perfect for me. Easy to setup, and the functionality is enough for my use. It only took me several hours to set up it, although I still haven’t figured it out how to upload images. Anyway, it works fine to me. One good article about the difference between these CMS could be found at: http://www.goodwebpractices.com/other/wordpress-vs-joomla-vs-drupal.html. Actually you could also use pmwiki, the one used by our department.

SVN Tutorial for Unix

A very good detailed svn tutorial for linux.
http://artis.imag.fr/~Xavier.Decoret/resources/svn/index.html

I found it is very easy to setup svn repository in Linux if only one person is going to use it. Under windows, I have to configure apache+subversion server on my desktop, and use TortoiseSVN to commit/update from my laptop. While in Linux, you just need to type a couple of commands. From laptop, you can access the code repository by using svn+ssh://url.of.desktop/home/user/svn project“. It is super convenient, no surprising as usual.

Converting .eps to .png Easily

http://scott.sherrillmix.com/blog/programmer/converting-eps-to-png-easily/

You can use ImageMagick to convert EPS file to PNG format easily. Simply

convert Img.eps Img.png

This will give you the png file with DPI 72. If you want to set the DPI for your png file, use

convert -density 300 Img.eps Img.png,

then an image with DPI 300 would be generated.

To process a batch of files, you can simply use command mogrify. For example,

mogrify -format png -density 300 *.eps