tag:blogger.com,1999:blog-40518605720818726822024-02-07T16:39:50.221+11:00Trials of a L3mming [Ph.DuD]The trials of an Australian Researcher.Shakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-4051860572081872682.post-74004133753155958242019-11-20T19:31:00.001+11:002019-11-20T20:12:48.886+11:00Setting Up Linux for Competitive Gaming (Its Mostly Simple!)I just wanted the fastest/easiest setup that ensures getting something like Counter-Strike Global Offensive setup with mouse acceleration off and DPI settings correct.<br />
<br />
I went with <a href="https://system76.com/pop">Pop OS!</a> as my distro because it has either AMD or NVIDIA drivers bundled with the ISO image used for installation. Then use something like <a href="https://rufus.ie/">Rufus</a> to create a bootable USB drive.<br />
<br />
Once your Linux distro is installed and assuming you're using Gnome-Shell (the default window manager for Pop OS, Ubuntu and Fedora), you want to install gnome tweak tool and under mouse, change the profile to flat to disable acceleration.<br />
<br />
To get DPI settings to match your previous settings, I used <span class="pln">razercfg to configure the mouse settings.</span><br />
<span class="pln"><br /></span>
<span class="pln">Then just install Steam and Lutris from the Pop Store and you're good to go!</span><br />
<br />
<span class="pln">EDIT: You can install Discord and other commercial applications from the <a href="https://snapcraft.io/store">SnapStore</a>. </span><br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-2677234352471027962018-02-24T13:39:00.002+11:002020-01-31T16:34:31.760+11:00Scientific Python Environment on Windows with TensorflowGoogle has made <a href="https://www.tensorflow.org/">Tensorflow </a>quite easy to install with GPU support, but getting it working along side SciPy and Numpy in a single Windows environment can be tricky. This is usually because Scipy looks for a specific build of Numpy that uses Intel MKL. This guide will allow you to set it up easily.<br />
<br />
<b>Firstly</b>, I setup <a href="https://sourceforge.net/projects/winpython/">WinPython </a>on my machine. You get Scikit packages, Jupyter, Scipy, Numpy, Spyder etc. in simple easy distribution that doesn't have to be installed but kept side-by-side with multiple setups. Avoid the "Zero" builds that have minimal packages. I used Python 3.5 Qt 5 installer.<br />
<br />
<b>Second</b>, go to the <a href="https://www.tensorflow.org/install/install_windows">Tensorflow </a>website and determine the <a href="https://developer.nvidia.com/cuda-toolkit">CUDA </a>version you need and then install CUDA of that version. If you install the incorrect version, you'll keep getting the error:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;">ImportError: Could not find 'cudart64_90.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit</span></blockquote>
Here, I installed CUDA 9.1 when instead the Python Package Index version of Tensorflow (v1.5 at the time of writing) required 9.0. Afterwards, install the cuDNN that matches the CUDA you have installed. This requires a sign up before login at the time of writing. Older versions of Tensorflow did not require cuDNN installed, but this is now compulsory.<br />
<br />
<b>Third</b>, install tensorflow-gpu via the WinPython Command Prompt by issuing the usual command that Google recommends:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;">pip install --upgrade --ignore-installed tensorflow-gpu </span></blockquote>
This will give you a working Tensorflow, Numpy environment, but Scipy will be broken giving the error:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"> from scipy.linalg import _fblas<br /><br />ImportError: DLL load failed: The specified module could not be found.</span></blockquote>
This is where you will need to install the Numpy MKL version, which you can find <a href="https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy">here</a>. Then use the WinPython Control Panel to upgrade the Numpy package. Make sure to download the Numpy MKL wheel to match your Python distribution.<br />
<br />
EDIT: If you choose the version of WinPython released just after the Tensorflow release you desire, then most of the libraries will be in-sync with the Tensorflow PIP package and therefore won't give you the issues with Scipy (and other libraries) above. <br />
<br />
That's it!<br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-60970139276929944232017-07-28T13:06:00.001+10:002017-09-22T15:33:30.298+10:00Setting up a Mac OSX Development Environment for VTK, ITK, Qt 4 and SMILII recently got access to a Mac and decided to improve support for SMILI on Mac OSX. This required setting up the Mac OSX development environment and so I log my experiences/steps in this post.<br />
<br />
Firstly some notes. This is to setup VTK 5 and/or 6, ITK 4.10+ and Qt 4 with the current version of Mac OSX at the time - Sierra (10.12).<br />
<br />
The first steps involved setting up <a href="https://brew.sh/">Homebrew</a>. This allows one to install Git and CMake for the command-line.<br />
<blockquote class="tr_bq">
brew install make</blockquote>
<br />
Next we installed Xcode from the AppStore. You should not run CMake on libraries until Xcode has been installed.<br />
<br />
Then (or during the XCode install) we download the required libraries for your environment:<br />
<br />
<ul>
<li>Insight Toolkit (ITK) - I used version 4.10.1, but newer versions of ITK 4 should be OK.</li>
<li>Visualisation Toolkit (VTK) - I used version 6.3.0, but also a modified version of 5.8.0 (for MSVC 2013) that I made available <a href="https://sourceforge.net/projects/smili-project/files/Dependencies/">here</a>. Versions newer than 6.3.0 had visualisation bugs introduced into SMILI.</li>
<li>Qt 4.8.x - Just use the home-brew version described here. I tried using version 4.8.6 that you can find <a href="https://download.qt.io/archive/qt/4.8/">here</a>. Download the .tar.gz version for Mac OSX. But it had issues, see below. So the HomeBrew version as described <a href="https://gist.github.com/robdvr/271e34785c8a43b1e093d2ee8e612aee">here</a>.</li>
</ul>
<h3>
Qt 4</h3>
<div>
I Failed: After Xcode was installed, I began compiling Qt. Turns out that using the zip version messes up the line endings and breaks the configure script. So make sure to download the TAR version. When compiling, There was a compile error for the '<a class="gwt-InlineHyperlink" href="https://codereview.qt-project.org/#/c/157137/1/src/gui/painting/qpaintengine_mac.cpp" style="color: rgb(34, 34, 34) !important; font-family: 'Arial Unicode MS', Arial, sans-serif; text-decoration: none; white-space: nowrap;">qpaintengine_mac.cpp</a>' file. The fix for Qt 4.8.6 is <a href="https://codereview.qt-project.org/#/c/157137/">here</a>. There are issues with 10.9 and libstd++ which I haven't figured out yet. I will update this side of the post once I have. I will leave the configure command I tried using here for future reference:</div>
<blockquote class="tr_bq">
<div style="background-color: white; font-family: Menlo; font-size: 11px; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">./configure -fast -release -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -DMACOSX_DEPLOYMENT_TARGET=10.9 -arch x86_64</span></div>
</blockquote>
<div>
You could also try 4.8.7 from <a href="https://download.qt.io/official_releases/qt/4.8/4.8.7/">here</a>. It required the same fix as 4.8.6 from <a href="https://codereview.qt-project.org/#/c/157137/">here</a>.<br />
<br /></div>
<div>
I Succeeded: by using the HomeBrew Qt4 version as described <a href="https://gist.github.com/robdvr/271e34785c8a43b1e093d2ee8e612aee">here</a>. I just did step 2 as I had a fresh install. No compilation, just downloaded and installed. This will become outdated at some point unless maintained, so you may need to search for other recipes. This <a href="https://github.com/cartr/homebrew-qt4">link</a> might help in that case.</div>
<br />
<br />
<h3>
ITK</h3>
No issues. Just build fine from source. I usually enable review to get access to less known ITK classes. I used the following CMake command to generate the project for Sublime Text:<br />
<blockquote class="tr_bq">
<div style="background-color: white; font-family: Menlo; font-size: 11px; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;">ccmake -G "Sublime Text 2 - Unix Makefiles" -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.6 ..</span></div>
</blockquote>
<h3>
VTK</h3>
I Failed: Once Qt 4 is built and installed, I enabled VTK_USE_QT to ON. I had two major issues. The first issue I had was with the duplicate symbols error with TIFF. Installing lib tiff with HomeBrew solved the problem, but could potentially caused crashes in certain versions of Mac OSX, so will post a better solution later. The second was a garbage collection compilation error that I have yet to find solution for.<br />
<br />
I succeeded: Compiling VTK 6.3 had no issues at all. I used the same CMake command as for ITK. I used deployment target of 10.6 to ensure support for Mac OSX 10.6.<br />
<br />
EDIT: I succeeded: Compiling VTK 5.8 by ensuring that the <span style="background-color: #f9f9f9; font-family: monospace, Courier; font-size: 12.699999809265137px;">VTK_REQUIRED_OBJCXX_FLAGS</span> was empty. This was because of a 'garbage collection not found' error. This is because GC memory management model has been deprecated and removed. See the <a href="https://www.vtk.org/Wiki/Cocoa_VTK">COCOA VTK page</a> for more details.<br />
<br />
<h3>
SMILI</h3>
Once the above dependencies are built, SMILI v1.01 had no issues. I reused the CMake command for ITK above. I built both 10.6 and 10.9 deployment targets for ITK, VTK and SMILI for testing.<br />
<br />
More will be added as I encounter/fix issues.<br />
<br />
Cheers Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-23035722805356059982016-01-22T14:27:00.002+11:002016-01-22T14:27:26.659+11:00Paperwhite eBook Reader Experiences for Research Papers and MathsI have been wanting an easier way to read journal papers for a while and always thought about getting an eBook reader, since e-ink should be suitable right?<br />
<br />
Well, reading a number of reviews and <a href="http://www.howtogeek.com/69481/how-to-convert-pdf-files-for-easy-ebook-reading/">guides</a>, it seems previous e-book readers didn't seem to handle PDFs well and most times didn't handle maths well either. That's why most guides etc. recommend tools like <a href="http://www.willus.com/archive/">K2pdfopt</a> to convert PDFs. But this year I though I'd give it a shot and test to see if the myths were true and I'm happy to report that it is not true for the new models, PDFs work great and maths are flawless.... at least for the Amazon Paperwhite 2015 model.<br />
<br />
Here's excerpts from my thesis (available open access <a href="http://arrow.monash.edu.au/vital/access/manager/Repository/monash:62607?query=Radon+Chandra">here</a>) displayed on the device. ;)<br />
<br />
Portrait Mode<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQZOATwKkHu0ekDqVRkxBNt58pWx6DJFmJYDzcKJKgrQ4ICcdbytXbNkzy2joZzktPOvOwD66AY94_m0kNJnWBgBb9geBAxYChkKFBgTLGiY6nPMs46PcEg5vxQ2zgKM5qkW7ObVv8f8w/s1600/IMG_20160122_130703.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQZOATwKkHu0ekDqVRkxBNt58pWx6DJFmJYDzcKJKgrQ4ICcdbytXbNkzy2joZzktPOvOwD66AY94_m0kNJnWBgBb9geBAxYChkKFBgTLGiY6nPMs46PcEg5vxQ2zgKM5qkW7ObVv8f8w/s400/IMG_20160122_130703.jpg" width="225" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmL4_w3ivcf5Gb9RLRJxbC3g6iMPRIUzVa28YgIOYuzA0SYRrbKw6EFGtPa6nVcMnTvWmVXa7AVyindhbB-2ceLNEPBx9eNy4gXrH9yZhgyu2qowB5cKRR98989-H00UavOdqzwMCtbyg/s1600/IMG_20160122_130908.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmL4_w3ivcf5Gb9RLRJxbC3g6iMPRIUzVa28YgIOYuzA0SYRrbKw6EFGtPa6nVcMnTvWmVXa7AVyindhbB-2ceLNEPBx9eNy4gXrH9yZhgyu2qowB5cKRR98989-H00UavOdqzwMCtbyg/s400/IMG_20160122_130908.jpg" width="225" /></a></div>
<br />
You can zoom like on any other tablet, with much slower update rates, but not a major drama since once you get the view you want, you can read it like paper.<br />
<br />
Portrait Mode Zoomed<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2_US51eWmO9ESLUi6HZkdR5QEhjKNer4ic-yxdzM8Ia669hhF64zXXK9wVGddK2emMwPsmR55wYUf86VfZ0wEZvCpOnU_unLpdf-FmoN0E3tIpMx6_WSFHF60ZIb04rOOwb1SEGUJCMU/s1600/IMG_20160122_130735.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2_US51eWmO9ESLUi6HZkdR5QEhjKNer4ic-yxdzM8Ia669hhF64zXXK9wVGddK2emMwPsmR55wYUf86VfZ0wEZvCpOnU_unLpdf-FmoN0E3tIpMx6_WSFHF60ZIb04rOOwb1SEGUJCMU/s400/IMG_20160122_130735.jpg" width="225" /></a></div>
<br />
I usually use the landscape mode, where each page is shown in three sections.<br />
<br />
Landscape mode<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIJT2ZbLzW5qx5P1z1q2oPHYuqmdBUjdpkjTMYeZ-GHPWNkH0p9InFJsk1w1HTgPTEs3t7506BTReLzw3zTXdFFjIZVZFF2qed47nQ3zwg6mHCxjMJij4y_oxsezqchs2pGQKvX7PvNRI/s1600/IMG_20160122_130541.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIJT2ZbLzW5qx5P1z1q2oPHYuqmdBUjdpkjTMYeZ-GHPWNkH0p9InFJsk1w1HTgPTEs3t7506BTReLzw3zTXdFFjIZVZFF2qed47nQ3zwg6mHCxjMJij4y_oxsezqchs2pGQKvX7PvNRI/s400/IMG_20160122_130541.jpg" width="400" /></a></div>
<br />
Surprisingly, the default PDF behavior was better than the converted PDF files were. Battery life is about a month and the reader also has back illumination for night reading, though would preferred a night mode (white text and black background) like some apps on Android tablets, but no biggy. I did find using the free <a href="http://calibre-ebook.com/">Calibre</a> to rename and reorder PDFs a must as the reader doesn't read the PDF meta data, so the PDFs are shown with filenames of the PDFs on the home screen. Adding sub-directories would be nice too on the home screen.<br />
<br />
All in all, I would highly recommend the reader to scientists for reading scholarly articles and properly displaying mathematics.<br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-33380337006822870632015-06-19T12:03:00.001+10:002019-09-03T23:16:38.611+10:00VTK 5 and FFMPEG shenanigans on WindowsOver the years, trying to get VTK 5 to work with FFMPEG has always been tricky. Thankfully, VTK 6 has no such problems, but for those that have legacy code that use VTK 5, this is still a problem.<br />
<br />
In this post I will cover some necessary tweaks, steps and links to getting FFMPEG IO working with your project that uses VTK 5, such as the 'Animate' plugin for<a href="http://smili-project.sourceforge.net/"> sMILX and SMILI</a>.<br />
<br />
Firstly, I have found VTK 5.8 to be far more stable and workable than 5.10.1. In my scientific visualisation software <a href="http://smili-project.sourceforge.net/">SMILI</a>, certain features don't work at all with the same code that runs fine on VTK 6 and 5.8.<br />
<br />
Secondly, it seems VTK 5 has issues with Visual Studio 2013 (required to support Windows 8), but <a href="https://github.com/bilke/VTK">a patched version of VTK 5.10.1 available on GitHub</a> works OK, though I had to fix a few round brackets here and here.<br />
<br />
For version 1.2 of FFMPEG, this is what I recently did to get VTK 5.8 working with FFMPEG. The best link for FFMPEG deprecation changes are found <a href="http://sgros.blogspot.com.au/2013/01/deprecated-functions-in-ffmpeg-library.html">here</a>. Summarised, I had to fix vtkFFMPEGWriter.cxx as the following:<br />
<ol>
<li>av_set_parameters - comment out</li>
<li>URL_WRONLY to AVIO_FLAG_WRITE</li>
<li>url_fopen to avio_open and url_fclose to avio_close</li>
<li>av_write_header to avformat_write_header, last arg to NULL</li>
</ol>
EDIT: You may also need AVCodecID, PKT_FLAG_KEY is replaced by AV_PKT_FLAG_KEY and replacing <code>CODEC_TYPE_VIDEO</code> with <code>AVMEDIA_TYPE_VIDEO.</code> <br />
<ol>
</ol>
<div>
EDIT 2: I have created a <a href="https://github.com/shakes76/VTK/tree/v5.8.0-ffmpeg">GitHub VTK 5.8.0 fork</a> with these changes applied.<br />
<br />
EDIT 3: GCC 9.1 causes issues. It can be fixed by setting CMAKE_CXX_FLAGS as -fpermissive -std=c++98 -DGLX_GLXEXT_LEGACY<br />
<br />
No changes are required for VTK 6.1.0 at the time of writing.</div>
<br />
Hope that helps<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-23183490861248922662015-06-05T15:11:00.000+10:002015-06-05T15:11:40.591+10:00Mesh/Surface Processing with Command-line SMILI toolsI recently had to do some processing for a prostate segmentation scheme I've been working on and thought some uses of SMILI tools would be helpful to others. Majority of surface processing tasks can be achieved with the milxModelApp in <a href="http://smili-project.sourceforge.net/">SMILI</a>, a easy to use open source medical imaging library and viewer.<br />
<br />
My tasks involved involved:<br />
<ol>
<li>copying scalars from an atlas mesh to lots of other meshes</li>
<li>using scalars to clip the meshes</li>
<li>computing the surface distance of the meshes to their corresponding labelled images that were created by clinical experts</li>
<li>computing the scalar statistics across the population of meshes (my meshes already have point to point correspondence) </li>
</ol>
Luckily, the <b>milxModelApp</b> application provides most of these without needing to script for multiple surfaces. Furthermore, the Qt framework is not required for these applications as they are VTK/ITK only applications (i.e. built on milxSMILI, the GUI-independent sub-library of SMILI).The following examples are for Version 0.998 (SMILI Release Beta 1).<br />
<br />
Each one of the above tasks can be achieved as:<br />
<ol>
<li>The <span style="color: #737dd5;">--scalarcopy </span> option in <b>milxModelApp </b>provides a way to do this. I did:<br />
<pre><!--StartFragment--><span style="font-size: x-small;"><span style="color: #737dd5;">milxModelApp</span><span style="color: #646482;"> </span><span style="color: #737dd5;">--scalarcopy</span><span style="color: #646482;"> </span><span style="color: #737dd5;">focus_atlases/focus_bladder_atlas.vtk</span><span style="color: #646482;"> </span><span style="color: #737dd5;">results/bladder/asm_bladder_*.vtk</span><span style="color: #646482;"> </span><span style="color: #737dd5;">-p</span><span style="color: #646482;"> </span><span style="color: #737dd5;">results_scalars/bladder/</span></span><!--EndFragment--></pre>
Copy scalars from atlas mesh (<span style="color: #737dd5; font-size: x-small;">focus_bladder_atlas.vtk</span>) to other meshes in directory (<span style="color: #737dd5; font-size: x-small;">results/bladder/asm_bladder_*.vtk</span>) and output to another directory with same names.</li>
<li>The <span style="color: #737dd5;">--clip <n></n></span><span style="color: #646482;"> </span><span style="color: #737dd5;"> </span>option in <b>milxModelApp </b>provides a way to do this. I did:<br />
<pre><!--StartFragment--><span style="font-size: x-small;"><span style="color: #737dd5;">milxModelApp</span><span style="color: #646482;"> </span><span style="color: #737dd5;">--clip</span><span style="color: #646482;"> </span><span style="color: #737dd5;">1</span><span style="color: #646482;"> </span><span style="color: #737dd5;">results_scalars/bladder/asm_bladder_*.vtk</span><span style="color: #646482;"> </span><span style="color: #737dd5;">-p</span><span style="color: #646482;"> </span><span style="color: #737dd5;">results_clipped/bladder/</span></span><!--EndFragment--></pre>
Clip meshes in directory keeping only parts with value of 1 and output to another directory with same names.</li>
<li>We need to write a script for the <b>milxHausdorffDistance </b>application<b> </b>that provides this using distance maps in a straight forward way. This script is now in the repository as scripts/
<!--StartFragment-->batch_hausdorff.py. An example usage of the application:<br />
<pre><!--StartFragment--><span style="font-size: x-small;"><span style="color: #737dd5;">milxHausdorffDistance</span><span style="color: #646482;"> </span><span style="color: #737dd5;">results_clipped/bone/asm_bone_4.vtk</span><span style="color: #646482;"> </span><span style="color: #737dd5;">-p</span><span style="color: #646482;"> </span><span style="color: #737dd5;">Hausdorff/bone/bone__</span><span style="color: #646482;"> </span><span style="color: #737dd5;">-o</span><span style="color: #646482;"> </span><span style="color: #737dd5;">Hausdorff/bone/bone__004.vtk</span><span style="color: #646482;"> </span><span style="color: #737dd5;">--label</span><span style="color: #646482;"> </span><span style="color: #737dd5;">manuals_renamed/bone/manual_case_bone_004.nii.gz</span><span style="color: #646482;"> </span><span style="color: #737dd5;">--labelvalue</span><span style="color: #646482;"> </span><span style="color: #737dd5;">1</span><span style="color: #646482;"> </span><span style="color: #737dd5;">-c</span><span style="color: #646482;"> </span><span style="color: #737dd5;">004</span></span><!--EndFragment--></pre>
The distance map of the manual is created and the distances stored on the mesh thus giving the surface distances to the manual.</li>
<li>The <span style="color: #737dd5;">--scalarstats </span>option in <b>milxModelApp </b>provides this. I did:<br /><pre><span style="font-size: x-small;"><span style="color: #737dd5;">milxModelApp</span><span style="color: #646482;"> </span><span style="color: #737dd5;">--scalarstats</span><span style="color: #646482;"> </span><span style="color: #737dd5;">Hausdorff/bladder/bladder__*.vtk</span><span style="color: #646482;"> </span><span style="color: #737dd5;">-o</span><span style="color: #646482;"> </span><span style="color: #737dd5;">bladder_stats.vtk</span></span></pre>
Compute scalars stats (mean, variance etc. per point) of meshes in directory and output single mesh (of first mesh) with stats as arrays in mesh. You can then use sMILX viewer to view the meshes and change the loaded arrays via the Right Click->Show->Load Array menu.</li>
</ol>
<div>
Note that the <b>milxDeformableModel</b> app is an application derived from <b>milxModelApp</b> and additionally provides options for voxelising surfaces and applying image orientation to surfaces.</div>
<div>
<br /></div>
Hope this helps<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-85643079116014668432015-02-28T16:28:00.002+11:002017-04-14T12:41:22.762+10:00Compiling VTK 5.8.0 on Windows 64 with Visual Studio 2013This is a quick post to cover the steps necessary to compile VTK 5.8.0, the most stable VTK 5 version in my experience, on Windows x64 with VS 2013 (to support Windows 8.1). The information is on the internet but scattered about so I thought I'd collect it just in case its useful for someone.<br />
<br />
EDIT: Note that VTK 5.8.0 builds out of the box on Ubuntu 16.04 still, if you ensure that you uncomment the line with the define for <code>GLX_GLXEXT_LEGACY </code>in the Rendering/vtkXOpenGLRenderWindow.cxx file. <br />
<br />
There are a few things that are incompatible with the new compiler. Firstly, the <span style="background-color: #eeeeee; color: #222222; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace , sans-serif; font-size: 13px; line-height: 16.8999996185303px; white-space: pre-wrap;">vtkOStreamWrapper </span>error. This is covered in great detail <a href="http://stackoverflow.com/questions/23090220/vtk-visualstudio2013-compile-error">here</a>. Basically replace the offending line with:<br />
<pre class="lang-cpp prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; margin: 0px; padding: 0px; white-space: inherit;"><span class="com" style="border: 0px; color: grey; margin: 0px; padding: 0px;">//VTKOSTREAM_OPERATOR(ostream&);</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">
vtkOStreamWrapper</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">&</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> vtkOStreamWrapper</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">::</span><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">operator</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;"><<</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">(</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">ostream</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">&</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> a</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">)</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">{</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">
</span><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">this</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">-></span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">ostr </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;"><<</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">(</span><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">void</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">*)&</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">a</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">;</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">
</span><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">return</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">*</span><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">this</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">;</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">
</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">}</span></code></pre>
Then there are the <span style="background-color: #eeeeee; color: #222222; font-family: "consolas" , "menlo" , "monaco" , "lucida console" , "liberation mono" , "dejavu sans mono" , "bitstream vera sans mono" , "courier new" , monospace , sans-serif; font-size: 13px; line-height: 16.8999996185303px; white-space: pre-wrap;">ifstream->read()</span> errors. Replace the<br />
<pre class="lang-cpp prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; margin: 0px; padding: 0px; white-space: inherit;"><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">if</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">(</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">this</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">-></span><span class="typ" style="border: 0px; color: #2b91af; margin: 0px; padding: 0px;">IFile</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">-></span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">read</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">(</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">result</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">,</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="lit" style="border: 0px; color: maroon; margin: 0px; padding: 0px;">80</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">)</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">==</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="lit" style="border: 0px; color: maroon; margin: 0px; padding: 0px;">0</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">)</span></code></pre>
with the<br />
<pre class="lang-cpp prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; margin: 0px; padding: 0px; white-space: inherit;"><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">if</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">(</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="kwd" style="border: 0px; color: darkblue; margin: 0px; padding: 0px;">this</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">-></span><span class="typ" style="border: 0px; color: #2b91af; margin: 0px; padding: 0px;">IFile</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">-></span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">read</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">(</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">result</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">,</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="lit" style="border: 0px; color: maroon; margin: 0px; padding: 0px;">80</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">).</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">fail</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">())</span></code></pre>
Lastly, there are the <span style="background-color: white; font-family: "consolas"; font-size: 13.4399995803833px;">make_pair</span> errors, solved <a href="http://vtk.1045678.n5.nabble.com/Building-VTK-5-8-0-for-Windows-8-64-bits-Visual-Studio-11-td5720806.html">here</a>. You need to replace the<br />
<pre class="lang-cpp prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><pre style="background: none 0% 0% repeat scroll white; color: black; font-family: Consolas; font-size: 13.4399995803833px;"><pre style="background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; font-family: Consolas;"><span style="color: blue;">this</span>->Map->insert(vtkstd::make_pair< vtkVariant, vtkVariant >(from, to));</pre>
</pre>
</pre>
with<br />
<pre class="lang-cpp prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><pre style="background: none 0% 0% repeat scroll white; color: black; font-family: Consolas; font-size: 13.4399995803833px;"><pre style="background-attachment: scroll; background-clip: initial; background-image: none; background-origin: initial; background-position: 0% 0%; background-repeat: repeat; background-size: initial; font-family: Consolas;"><span style="color: blue;">this</span>->Map->insert(<span style="color: #6f008a;">vtkstd</span>::make_pair(<span style="color: grey;">from</span>, <span style="color: grey;">to</span>)); <span style="color: green;">// Addendum</span></pre>
</pre>
</pre>
in the vtkMapArrayValues.cxx file. You might need to add the include:<br />
<pre class="lang-cpp prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><pre style="background: none 0% 0% repeat scroll white; color: black; font-family: Consolas; font-size: 13.4399995803833px;"><span style="color: blue;">#ifdef</span> <span style="color: #6f008a;">_WINDOWS</span>
<span style="color: blue;">#include</span> <span style="color: #a31515;"><functional></functional></span> <span style="color: green;">// Addendum for vs11 to find 'greater'</span>
<span style="color: blue;">#endif</span></pre>
</pre>
<div>
to vtkAdjacencyMatrixToEdgeTable.cxx. I also had to add the above include and </div>
<div>
<pre class="lang-cpp prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><span style="color: #222222; line-height: 16.8999996185303px; white-space: normal;">#include <algorithm></algorithm></span></pre>
</div>
<div>
to vtkAdjacencyMatrixToEdgeTable.cxx, vtkNormalizeMatrixVectors.cxx, vtkPairwiseExtractHistogram2D.cxx, vtkParallelCoordinatesRepresentation.cxx, vtkChartXY.cxx, vtkControlPointsItem.cxx, to get rid of std max and min errors, </div>
<div>
<br /></div>
HTHCheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-3286170268565746682015-02-12T17:17:00.000+11:002015-02-12T17:17:48.995+11:00HP 4000b Bluetooth Mouse and UbuntuThis quick post cover howto get the HP 4000b Bluetooth mouse working flawlessly with Ubuntu 14.10 + (and maybe even older versions). These bluetooth mice are useful for ultra-portable devices that have no or few USB ports, like my Dell XPS 13, keeping the port free for other uses.<br />
<br />
The HP 4000b mouse is an affordable bluetooth mouse that does work out of the box with Ubuntu but drops out after use for a few minutes or so. This <a href="http://ubuntuforums.org/showthread.php?t=2159645&page=6&p=12926730#post12926730">post</a> covers the solution to this problem that worked for me, and this <a href="http://askubuntu.com/questions/286112/bluetooth-loses-connection-with-mouse-in-13-04/345871#345871">post</a> helpful for <a href="http://linrunner.de/en/tlp/tlp.html">TLP</a> users.<br />
<br />
In summary, add the following to your rc.local file (the one I used was /etc/rc.local):<br />
<blockquote class="tr_bq">
<pre class="bbcode_code" style="background: none repeat-x rgb(239, 239, 239); border: 1px inset; direction: ltr; font-family: 'Ubuntu Mono', monospace; font-size: 14px; height: 156px; line-height: 14px; overflow: auto; padding: 6px; word-wrap: normal;"># Prevents the Bluetooth USB card from getting reset which disconnects the mouse
BTUSB_DEV="8087:07dc"
BTUSB_BINDING="$(lsusb -d "$BTUSB_DEV" |
cut -f 1 -d : |
sed -e 's,Bus ,,' -e 's, Device ,/,' |
xargs -I {} udevadm info -q path -n /dev/bus/usb/{} |
xargs basename)"
echo "Disabling autosuspend for Bluetooth USB Soundcard: $BTUSB_BINDING..."
echo -1 > "/sys/bus/usb/devices/$BTUSB_BINDING/power/autosuspend_delay_ms"</pre>
</blockquote>
And in the TLP config (<span style="background-color: #eeeeee; color: #222222; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; line-height: 18.2000007629395px; white-space: pre-wrap;">/etc/default/tlp)</span>, add the<span style="background-color: white; color: #333333; font-family: UbuntuRegular, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; font-size: 14px; line-height: 18.2000007629395px;"> </span><strong style="background-color: white; border: 0px; color: #333333; font-family: UbuntuRegular, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; font-size: 14px; line-height: 18.2000007629395px; margin: 0px; padding: 0px; vertical-align: baseline;">USB_BLACKLIST="8087:07da"</strong>. The ID for my device was <span style="background-color: #efefef; font-family: 'Ubuntu Mono', monospace; font-size: 14px; line-height: 14px;">8087:07dc</span> as in the rc.local file. These IDs need to match and can be found using <span style="background-color: #eeeeee; color: #222222; font-family: 'Ubuntu Mono', 'Ubuntu Beta Mono A', Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; line-height: 18.2000007629395px; white-space: pre-wrap;">lsusb</span>.<br />
<br />
HTH<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-5487547454586329092015-01-25T23:06:00.002+11:002015-12-19T09:59:43.573+11:00Visualizing 32-bit Integer PGMs (eg. from FTL) or other ASCII Image FormatsIn this post I will post some Python code for visualising ASCII image formats such as PGMs (esp. from the <a href="http://finitetransform.sourceforge.net/">Finite Transform Library (FTL)</a>). These formats are commonly used because of their simplicity in implementation.<br />
<br />
EDIT: The sMILX Viewer (v1.0 Alpha and above), part of the <a href="https://sourceforge.net/projects/smili-project/">SMILI project</a> for scientific visualisation now supports these PGMs. Just drag and drop the file into the viewer window to visualise them!<br />
<br />
The ASCII PGM format for example has a simple header made up of a format string (made of two characters) such as 'P2' on the first line, followed by a comment line, the dimensions of the image (width and height) and the bit depth. Finally the data is next. An example is given below:<br />
<blockquote class="tr_bq">
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;">P2</span></blockquote>
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"># Generated PGM.</span></blockquote>
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;">101 101</span></blockquote>
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;">255</span></blockquote>
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;">184 180 188 199 202 203 200 195 195 202 198 186 181 156 ........</span></blockquote>
</blockquote>
Since most PGM and image viewers always expect a bit depth of 8-bit, the result isn't always shown correctly. I have written a simple Python module to do this type of reading and also utilise 32-bit PNGs as well. The full module can be found in this <a href="https://gist.github.com/shakes76/08cac163a7acf1ad35ac">gist</a><span id="goog_1547237947"></span><span id="goog_1547237948"></span><a href="https://www.blogger.com/"></a>. The section for PGMs is as follows:<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">def</span> <span style="color: #0066bb; font-weight: bold;">readPGM</span>(name):
<span style="color: #dd4422;">'''</span>
<span style="color: #dd4422;"> Read a PGM image, where the PGM format is that of the FTL library for NTTs and FRTs.</span>
<span style="color: #dd4422;"> This is a slightly modified format where values are not limited to 8-bit values.</span>
<span style="color: #dd4422;"> </span>
<span style="color: #dd4422;"> Returns array of image and bit depth (image, depth)</span>
<span style="color: #dd4422;"> '''</span>
inFile <span style="color: #333333;">=</span> <span style="color: #007020;">open</span>(name,<span style="background-color: #fff0f0;">"r"</span>)
<span style="color: #888888;">#read header</span>
formatLine <span style="color: #333333;">=</span> inFile<span style="color: #333333;">.</span>readline()
commentLine <span style="color: #333333;">=</span> inFile<span style="color: #333333;">.</span>readline()
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: black; font-weight: bold;">not</span> <span style="background-color: #fff0f0;">"P2"</span> <span style="color: black; font-weight: bold;">in</span> formatLine:
<span style="color: #008800; font-weight: bold;">print</span> <span style="background-color: #fff0f0;">"Error: PGM not in correct format (P2)"</span>
<span style="color: #008800; font-weight: bold;">print</span> <span style="background-color: #fff0f0;">"Comment:"</span>, commentLine
width, height <span style="color: #333333;">=</span> [<span style="color: #007020;">int</span>(x) <span style="color: #008800; font-weight: bold;">for</span> x <span style="color: black; font-weight: bold;">in</span> inFile<span style="color: #333333;">.</span>readline()<span style="color: #333333;">.</span>split()] <span style="color: #888888;"># read dimensions</span>
<span style="color: #008800; font-weight: bold;">print</span> <span style="background-color: #fff0f0;">"PGM Size:"</span>, width, <span style="background-color: #fff0f0;">"x"</span>, height
bitDepth <span style="color: #333333;">=</span> [<span style="color: #007020;">int</span>(x) <span style="color: #008800; font-weight: bold;">for</span> x <span style="color: black; font-weight: bold;">in</span> inFile<span style="color: #333333;">.</span>readline()<span style="color: #333333;">.</span>split()] <span style="color: #888888;"># read bit Depth</span>
imageList <span style="color: #333333;">=</span> []
<span style="color: #008800; font-weight: bold;">for</span> line <span style="color: black; font-weight: bold;">in</span> inFile: <span style="color: #888888;"># read remaining lines</span>
valueList <span style="color: #333333;">=</span> [<span style="color: #007020;">int</span>(x) <span style="color: #008800; font-weight: bold;">for</span> x <span style="color: black; font-weight: bold;">in</span> line<span style="color: #333333;">.</span>split()] <span style="color: #888888;">#read integers on each line</span>
<span style="color: #008800; font-weight: bold;">for</span> value <span style="color: black; font-weight: bold;">in</span> valueList:
imageList<span style="color: #333333;">.</span>append(value) <span style="color: #888888;">#append as 1D list</span>
<span style="color: #888888;"># print imageList</span>
<span style="color: #888888;">#store as array</span>
image <span style="color: #333333;">=</span> np<span style="color: #333333;">.</span>array(imageList)<span style="color: #333333;">.</span>reshape(height, width)
<span style="color: #008800; font-weight: bold;">return</span> image, bitDepth
</pre>
</td></tr>
</tbody></table>
</div>
<br />
Then to load results from FTL, simply use a script as:<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: #888888;"># -*- coding: utf-8 -*-</span>
<span style="color: #dd4422;">"""</span>
<span style="color: #dd4422;">Test Read PGM member</span>
<span style="color: #dd4422;">Created on Sun Jan 25 21:52:38 2015</span>
<span style="color: #dd4422;">@author: shakes</span>
<span style="color: #dd4422;">"""</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">imageio</span>
image, depth <span style="color: #333333;">=</span> imageio<span style="color: #333333;">.</span>readPGM(<span style="background-color: #fff0f0;">"lena.pgm"</span>)
frtSpace, depth <span style="color: #333333;">=</span> imageio<span style="color: #333333;">.</span>readPGM(<span style="background-color: #fff0f0;">"frtSpace.pgm"</span>)
<span style="color: #888888;">#Plot</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">matplotlib.pyplot</span> <span style="color: #008800; font-weight: bold;">as</span> <span style="color: #0e84b5; font-weight: bold;">plt</span>
<span style="color: #888888;">#plot images</span>
fig, ax <span style="color: #333333;">=</span> plt<span style="color: #333333;">.</span>subplots(nrows<span style="color: #333333;">=</span><span style="color: #0000dd; font-weight: bold;">1</span>, ncols<span style="color: #333333;">=</span><span style="color: #0000dd; font-weight: bold;">2</span>, figsize<span style="color: #333333;">=</span>(<span style="color: #0000dd; font-weight: bold;">16</span>, <span style="color: #0000dd; font-weight: bold;">5</span>))
plt<span style="color: #333333;">.</span>gray()
ax[<span style="color: #0000dd; font-weight: bold;">0</span>]<span style="color: #333333;">.</span>imshow(image)
ax[<span style="color: #0000dd; font-weight: bold;">0</span>]<span style="color: #333333;">.</span>axis(<span style="background-color: #fff0f0;">'off'</span>)
ax[<span style="color: #0000dd; font-weight: bold;">0</span>]<span style="color: #333333;">.</span>set_title(<span style="background-color: #fff0f0;">'Image'</span>)
ax[<span style="color: #0000dd; font-weight: bold;">1</span>]<span style="color: #333333;">.</span>imshow(frtSpace)
ax[<span style="color: #0000dd; font-weight: bold;">1</span>]<span style="color: #333333;">.</span>axis(<span style="background-color: #fff0f0;">'off'</span>)
ax[<span style="color: #0000dd; font-weight: bold;">1</span>]<span style="color: #333333;">.</span>set_title(<span style="background-color: #fff0f0;">'FRT of Lena'</span>)
plt<span style="color: #333333;">.</span>show()
</pre>
</td></tr>
</tbody></table>
</div>
<br />
The result is a <a href="http://matplotlib.org/">Matplotlib</a> plot of the images, both of Lena and her FRT space:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhylSSrWa6hxAX-ko8JAZmwSubJ9MNHiuuJ0Lm_1qEaOR_auncRCHDnEl_JgpNoM1Iljj1NVg3_-hMsmjgg5_829TMol_7dsuER0Y1ljTR8bTfBGlwQQigkP5rswKGSJSg0mC8ZdXGTgOg/s1600/frt.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhylSSrWa6hxAX-ko8JAZmwSubJ9MNHiuuJ0Lm_1qEaOR_auncRCHDnEl_JgpNoM1Iljj1NVg3_-hMsmjgg5_829TMol_7dsuER0Y1ljTR8bTfBGlwQQigkP5rswKGSJSg0mC8ZdXGTgOg/s1600/frt.png" width="400" /></a></div>
You can adapt it for your image format by just changing what/how the header is read. Feel free to fork the <a href="https://gist.github.com/shakes76/08cac163a7acf1ad35ac">gist</a> as I will put the latest version there. This module is part of a pure Python version of FTL coming soon, so watch this space..... better yet... Follow!<br />
<br />
PS: A FTL plugin for my scientific visualisation software <a href="http://smili-project.sourceforge.net/">SMILI</a> is on the way too. More soon in the next version.<br />
<br />
UPDATE: Scientific visualisation (open-source) software <a href="http://smili-project.sourceforge.net/">SMILI</a> supports 32-bit PGMs natively now via the FTL plugin. Get the binaries from <a href="https://github.com/shakes76/smili/releases">GitHub </a>or <a href="https://sourceforge.net/projects/smili-project/files/Stable%20Binaries/">Sourceforge</a>.<br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-34331842042151441152014-11-20T14:28:00.000+11:002014-11-22T16:15:36.164+11:00SMILI: A simple open-source framework for scientific visualisation I'm pleased to announce the release of SMILI, a simple framework for scientific visualisation, under a BSD license on <a href="http://smili-project.sourceforge.net/">SourceForge </a>and <a href="https://github.com/shakes76/smili">GitHub</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilWvtarz2dUXE31i8vLisoRV-UAiAroL-hnNhrCY62E6UDmMuf8jH_pEGCYybDYkHT5Y4_WZAFqXy01R6Kej_ttw3avOozoNhijZ_8Ei4khwoxwdo_RJRVTcAYBlBGC3kUsWAWJBXkei0/s1600/smili3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilWvtarz2dUXE31i8vLisoRV-UAiAroL-hnNhrCY62E6UDmMuf8jH_pEGCYybDYkHT5Y4_WZAFqXy01R6Kej_ttw3avOozoNhijZ_8Ei4khwoxwdo_RJRVTcAYBlBGC3kUsWAWJBXkei0/s1600/smili3.png" height="166" width="320" /></a></div>
<br />
In this post, I thought I would cover some of the cool features and command-line utilities available for researchers and developers. The overall documentation can be found <a href="http://smili-project.sourceforge.net/doc.html">here</a>. This post will hopefully be complimentary to this and the videos of SMILI already available on <a href="https://www.youtube.com/channel/UCD-hU6IF2qGlz7roexAUj1Q">YouTube</a>.<br />
<br />
Some of the additional features of SMILI are the ability to share the same processing and display capabilities of the GUI applications with their command-line counterparts. For example, you have the following command-line tools to assist you in your research:<br />
<br />
<ol>
<li>milxImageViewer and milxModelViewer - These are fast, no-nonsense viewers for n-D images and 3D polygonal data, such as triangulated surfaces. They don't load pesky plugins, they just allow you to view your data fast. The right click options are still available, especially the processing elements. However, any interaction between windows is no longer possible for obvious reasons. You can use sMILX for this.</li>
<li>milxOverlay and milxAnimate - These applications allow you to take screenshots/movies of models and images together with pre-defined views (which can be created in sMILX). This is great for visually inspecting your results or for websites when there are a lot of them. There is a batch script in 'scripts/' directory to batch these applications over multiple threads for quick generation.</li>
<li>milxImageApp and milxModelApp - These are the 'swiss-army knife' like applications for images and models respectively. With them you can simply process all the images/models you provide via the command-line in the same way with many of the algorithms available in sMILX. For example, to threshold labelled images (having Nifti format) within a certain range and storing result in 'auto', we could simply:<br /><span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">milxImageApp --threshold --above 225 --below 180 *.nii.gz -p auto/auto_</span></li>
<li>milxLabelVisualisation - Sometimes it is necessary to visualise labelled images using iso-surfacing or marching cubes or volume rendering with certain colour maps. This application provides a way of doing these things with off-screen rendering.</li>
<li>milxAssistant - This application provides a simple web browser interface to explore the SMILI documentation in a similar fashion to Qt Assistant.</li>
</ol>
<br />
As updates occur, I will post notices on <a href="https://twitter.com/shakes76">twitter </a>and <a href="https://plus.google.com/b/112408772560855274708/112408772560855274708/posts/p/pub?cfem=1">Google+</a>. Major development updates will be posted here in this blog. Currently, a journal publication for SMILI is under review entitled:<br />
<blockquote class="tr_bq">
"Focused Shape Visualisation via the Simple Medical Imaging Library Interface"<br />
Visualisation and Computer Graphics, IEEE Transactions on, 2014, Submitted</blockquote>
Upon acceptance, more details, plugins and revision history will be released. If you have any feedback, feel free to post as a <a href="https://sourceforge.net/p/smili-project/tickets/?source=navbar">ticket</a>, email the <a href="https://lists.sourceforge.net/lists/listinfo/smili-project-users">mailing-list</a> or message me on <a href="https://sourceforge.net/projects/smili-project/?source=directory">SourceForge</a>.<br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-81175511084624570772014-10-06T18:43:00.002+11:002015-01-27T06:24:22.536+11:00Robust Digital Image Reconstruction ExampleIn this post, we discuss how to employ the digital image reconstruction technique of Chandra <i>et al.</i> (2014):<br />
<br />
<a class="gsc_a_at" href="http://scholar.google.com.au/citations?view_op=view_citation&hl=en&user=tKe_olQAAAAJ&citation_for_view=tKe_olQAAAAJ:YOwf2qJgpHMC" style="background-color: white; color: #660099; font-family: Arial, sans-serif; font-size: 16px; padding: 8px 0px; text-decoration: none;">Robust digital image reconstruction via the discrete Fourier slice theorem</a><br />
<div class="gs_gray" style="background-color: white; border: 0px; color: #777777; font-family: Arial, sans-serif; font-size: 13px; line-height: 16.1200008392334px; margin: 0px; padding: 0px;">
S Chandra, N Normand, A Kingston, JP Guedon, I Svalbe</div>
<div class="gs_gray" style="background-color: white; border: 0px; color: #777777; font-family: Arial, sans-serif; font-size: 13px; line-height: 16.1200008392334px; margin: 0px; padding: 0px;">
IEEE Sig. Proc. Lett. (2014)</div>
<br />
using the <a href="http://finitetransform.sourceforge.net/">FTL</a> (implemented in C, available via LGPL license).<br />
<br />
This method takes a sufficient set of discrete (rational angle) projections assuming the Dirac pixel model, i.e. digital image sampling where lines have said to have sampled a pixel iff the line goes through the centre of the pixel, and reconstructs them in O(nlogn), where n=N^2. Sufficiency is classified as those projections meeting the Katz criterion, i.e. basically all bins are sampled at least once and no unambiguous solution (i.e. a ghost) cannot fit within the image. See also:<br />
<br />
<a class="gsc_a_at" href="http://scholar.google.com.au/citations?view_op=view_citation&hl=en&user=tKe_olQAAAAJ&citation_for_view=tKe_olQAAAAJ:9yKSN-GCB0IC" style="background-color: white; color: #660099; font-family: Arial, sans-serif; font-size: 16px; padding: 8px 0px; text-decoration: none;">Fast Mojette transform for discrete tomography</a><br />
<div class="gs_gray" style="background-color: white; border: 0px; color: #777777; font-family: Arial, sans-serif; font-size: 13px; line-height: 16.1200008392334px; margin: 0px; padding: 0px;">
SS Chandra, N Normand, A Kingston, J Guédon, I Svalbe</div>
<div class="gs_gray" style="background-color: white; border: 0px; color: #777777; font-family: Arial, sans-serif; font-size: 13px; line-height: 16.1200008392334px; margin: 0px; padding: 0px;">
arXiv preprint arXiv:1006.1965</div>
<div class="gs_gray" style="background-color: white; border: 0px; color: #777777; font-family: Arial, sans-serif; font-size: 13px; line-height: 16.1200008392334px; margin: 0px; padding: 0px;">
<br /></div>
Once you have FTL built, you should have four binaries for this method:<br />
<br />
<ul>
<li>fmt_angles - Select the angle type and generate the rational angles for given n and N, the image and reconstruction (FFT space) sizes respectively.</li>
<li>mt - Compute the discrete (rational angle) projections of the image, also known as the Mojette transform (MT).</li>
<li>mt2frt - Convert the projections to those of the FRT/DRT, which are the inverse FFTs of the slices of the 2D FFT.</li>
<li>ifrt - To reconstruct the resulting FRT projections in O(nlogn), no relation to the n before.</li>
</ul>
<br />
To illustrate the process we given a tutorial here of the whole process.<br />
<br />
1. First, we crop Lena image to a 128x128 image of Lena from the centre:<br />
<br />
<blockquote class="tr_bq">
./crop lena512.pgm 128 128 0 lena128.pgm</blockquote>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYzlJtEZAIipOLgzLqC4CXGzmf-Lhie1BtPBuekKNCVEPU2dGolpvrzIQ0yZG5kfeDB_CE3IBwj1-quwiGcGQn860UsSuDCbqvD7vcaTOVxPCIhQv5qJNxSmKwhDWjE4Q4wtWVLDD15Fs/s1600/lena128.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYzlJtEZAIipOLgzLqC4CXGzmf-Lhie1BtPBuekKNCVEPU2dGolpvrzIQ0yZG5kfeDB_CE3IBwj1-quwiGcGQn860UsSuDCbqvD7vcaTOVxPCIhQv5qJNxSmKwhDWjE4Q4wtWVLDD15Fs/s1600/lena128.png" height="200" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
2. We create the angle set, we choose the L1 minimal set since it has a nice symmetry:<br />
<blockquote class="tr_bq">
./fmt_angles 128 256 1 mt_angles_128_in_256.txt</blockquote>
3. Next we compute the MT:<br />
<blockquote class="tr_bq">
./mt lena128.pgm mt_angles_128_in_256.txt mt_lena128.pgm</blockquote>
Note that if you already have projections, such as those of a sinogram, then see this <a href="https://groups.google.com/forum/#!topic/finite-transform-library/Liy_v1RRIWY">Google Groups discussion</a>. You can find the publication by my colleague Andrew Kingston on how to do this <a href="http://staff.itee.uq.edu.au/lovell/aprs/dicta2003/pdf/0263.pdf">here</a>.<br />
4. Convert the MT projections into FRT space<br />
<blockquote class="tr_bq">
./mt2frt mt_lena128.pgm mt_angles_128_in_256.txt 128 256 1.0 frt_lena128.pgm</blockquote>
5. Invert the FRT projections in O(nlogn) using the discrete Fourier slice theorem<br />
<blockquote class="tr_bq">
./ifrt frt_lena128.pgm recon_lena128.pgm</blockquote>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ufkQEyrH9WgcKXcx2YiWonqFsiv81F4uRLpK-WC06h7pWZ4oVbFXsjoFsFzgrFclDsvh2rc0q5q7VsXH_gKE8PmbL8f2mJpOVrlPRYpErNpF_cXHReNkMYketNXHxfg-gNwmCiqkotk/s1600/recon_lena128.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ufkQEyrH9WgcKXcx2YiWonqFsiv81F4uRLpK-WC06h7pWZ4oVbFXsjoFsFzgrFclDsvh2rc0q5q7VsXH_gKE8PmbL8f2mJpOVrlPRYpErNpF_cXHReNkMYketNXHxfg-gNwmCiqkotk/s1600/recon_lena128.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
This gives our nxn result reconstructed and padded into the NxN space.<br />
<br />
EDIT: See <a href="http://l3mmings.blogspot.com.au/2015/01/visualizing-32-bit-integer-pgms-eg-from.html">my other post</a> about visualising these and FTL (or PGM files) results in general.<br />
<br />
HTH<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com2tag:blogger.com,1999:blog-4051860572081872682.post-48844994494633460922014-08-09T17:31:00.004+10:002014-08-30T11:01:54.290+10:00Australian Dell XPS 13 Touch (9333) 2014 with Ubuntu/Linux ExperiencesAfter many hours trying of trying to get my old laptop battery life above 3 hrs, I finally bit the bullet and bought a new laptop.<br />
<br />
I eventually went for the Dell XPS 13 Touch (i7, 256 GB SSD, 8 GB RAM) and I'd thought I should put down a few words about my experiences for anyone looking for a good portable developer laptop.<br />
<br />
My findings in summary: a damn fine developer laptop! Great backlit keyboard, Ubuntu works (details below), fantastic battery life, quiet and portable to the max.<br />
<br />
Basically, weights as much as a 10" tablet, about the same size despite having a 13" Full HD touch screen. First day I took it to work and on battery compiled ITK within 10 minutes (as well as some custom libraries), installed a ton of stuff from the repositories, browsed the web, did some development and remote login work and still only consumed only two thirds the battery at the end of the day. My colleagues also loved the styling and were impressed overall.<br />
<h4>
Why not a Mac Book Pro?</h4>
I have to say the Mac was tempting. It was a little cheaper (lower spec though), probably more robust (by a little) and more battery life (only just) and Unix style OS with native MS Office. In the end, and after having used a Mac for a few weeks now for deploying some software, it became a matter of personal belief of what software should be about: <a href="http://en.wikipedia.org/wiki/Free_and_open_source_software">FLOSS</a>.<br />
<br />
For example: It seems to customise and to get 'non-standard' elements working requires buying stuff. Want to write to NTFS filesystems? Buy software. Want to customise dock? Buy app. Even the open-source and free <a href="https://itunes.apple.com/us/app/scite/id466385995?mt=12&ign-mpt=uo%3D4">SciTE is available for purchase on the app store</a>. Sigh. This together with no middle mouse click, no uninstall for installers and deployment issues for 10.6 and 10.9 push me over the edge and I don't regret one bit (so far... hehehe).<br />
<h4>
Installing Ubuntu </h4>
Installing Ubuntu was almost seamless. As per usual, follow all the backup routines etc. before installing. A few minor hurdles were encountered:<br />
<ul>
<li>Kernel 3.14 is required to get the best battery life for i7's, thus I used distrowatch.com search page to work out the distros that had the latest linux kernel. This was OpenSUSE factory and Ubuntu Snapshot </li>
<li>I used the Ubuntu snapshot (06/08/2014) and the iso to usb installer that comes with Linux Mint (which was installed on my desktop) to put it on a USB stick since the XPS 13 has no DVD-drive.</li>
<li>Make sure to shrink the Windows partition in Windows as during the partitioning stage, it kept trying to install Ubuntu to the USB stick since it was a large (16 GB) stick and only disk with space, making it difficult to resize in the installer itself. With all the EFI stuff, it better to let the installer set it up for you. OpenSUSE installer did the same thing too.</li>
<li>After the installer finished and I rebooted, everything worked! Even the touch screen. I was shocked lol. Not usually my experience in the last 10 years with Linux of any flavour. Linux has come a long way in the last few years! Even Ubuntu looked fabulous and it was good to hear the drum sound again after being away from it for so long. ;D</li>
<li>When I say everything, I kind of exaggerated a little. the Wifi didn't because of propriety firmware that just needs <i>linux-firmware-nonfree</i> package installed. </li>
<li>The touch device still has a <a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1305522">bug</a> and is not recognised properly, though it works fine. I got <a href="http://askubuntu.com/questions/130393/how-to-configure-the-touchpad-middle-click">middle mouse click working with three finger tap</a> (disabled on Ubuntu by default.... wtf).</li>
</ul>
Hope this helps someone. <br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com1tag:blogger.com,1999:blog-4051860572081872682.post-50055518376602429482014-07-27T21:45:00.001+10:002014-08-27T23:00:18.908+10:00Linux Distros for Laptops and Power Saving Tweaks for a 2nd Gen i7 MachineIn this post I will note down my experiences in finding a suitable Linux distro for my HP Pavilion dv6 and some power-saving or improving battery life tweaks I now use.<br />
<br />
This laptop is really a portable desktop, that is a burn-top rather than a laptop. It is heavy (~2.5 kg), power hungry but very powerful, when it is not overheating and burning your lap.<br />
<br />
The first distro I tried was OpenSUSE 12.3 with KDE. This worked out of the box with everything and was a joy to use when AC is plugged in. However, the battery life wasn't great (~1 hour) and it over heated constantly. I upgraded to 13.1, but that process broke my C++ development environment as some libraries became unreachable. Probably fixable but I felt it time to try something else/new.<br />
<h4>
Battery life and overheating</h4>
To improve battery life, I installed <a href="http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html">TLP</a> and followed this very useful <a href="http://www.howtogeek.com/55185/how-to-maximize-the-battery-life-on-your-linux-laptop/">article on howtogeek</a> to tweak this as much as possible.<br />
<br />
It is also important to update to the latest video card drivers, AMD/ATI drivers in my case. ATI has settings in Catalyst for power saving and OpenSUSE has improvements for Radeon cards. To get a sense of what is consuming the power, install PowerTop.<br />
<br />
To reduce overheating, I underclocked the CPUs to a max of 1.8GHz from 2.0GHz on AC power, to 1.2 GHz and changed the default governor to 'powersave' when on battery. BTW, this trick also works on windows by changing the max execution from 100% to 90% etc. (see <a href="http://www.addictivetips.com/windows-tips/how-to-prevent-your-laptop-from-overheating-windows-7/">this post</a>). This improved battery life and reduced stuttering from overheating, especially if streaming video.<br />
<br />
The result was an increase of battery life from 1hr to 2.5 hrs and almost zero fan noise on OpenSUSE 13.1 KDE. All bets are off when you start compiling code however. ;) <br />
<h4>
Linux Distros for Laptops</h4>
KDE is probably the best desktop manager right now along with Cinnamon, but both are processor hungry etc. and suited to desktops so I started to look into other options.<br />
<br />
I read that XFCE and LXDE managers would be better for laptops in various places. I had tried these before a while ago and they were very lightweight and snappy. But they were missing important customisation features and looked too stripped down and ugly a few years ago.<br />
<br />
I tried XFCE via <a href="http://xubuntu.org/">XUbuntu 14.04</a> and it was great and looked stylish. Installed flawlessly, boots fast and just works (WiFi, boot splash, suspend etc.). The search feature in the menu like KDE and Cinnamon is also great, but had issues picking out all the installed apps. My touch pad lost its ability to track three fingers and that, combined with a warning that BIOS detected 'overheating', pushed me to look elsewhere. I would reccomend this for older machines or those lacking CPU power.<br />
<br />
Next one I tried was <a href="http://elementaryos.org/">elementaryOS</a>, an Ubuntu based distro which I saw running on a colleague's machine. It looked stunning, snappy and workable. After installation, I got the same BIOS error (not surprising since the stable version at the time was based on Ubuntu 12.04) and the panel was very difficult to customise. It looked so good I wanted to stay but even after an hour of searching on the web I couldn't get a working CPU monitor or weather indicators. A distro I would setup for the Mrs or family as it was clean and elegant.<br />
<br />
In the end, I ended up re-installing XFCE version of OpenSUSE 13.1 and haven't looked back (so far). The Ubuntu version of XFCE looks better, but the BIOS error disappeared and the track pad worked again. Combined with Cairo-Dock, the final result is reasonable looking and battery life slightly better than the KDE version. I simply switch between KDE and XFCE depending if on battery or not.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgtvqdxy1mFUrPhSyKTo4niiDDYmU8aUSxN1-kDMSE6kd9p1fKBIVoWocL4BrtugyhfSggX_f5T7J1FV1zSJKusyWdvWC8pCMaQpV73sCUCew09Gp541KWl4-y-UOZTo5Fmhvl_G4nxMo/s1600/Screenshot+-+07272014+-+09:36:06+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgtvqdxy1mFUrPhSyKTo4niiDDYmU8aUSxN1-kDMSE6kd9p1fKBIVoWocL4BrtugyhfSggX_f5T7J1FV1zSJKusyWdvWC8pCMaQpV73sCUCew09Gp541KWl4-y-UOZTo5Fmhvl_G4nxMo/s1600/Screenshot+-+07272014+-+09:36:06+PM.png" height="179" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">OpenSUSE with XFCE and Cairo-Dock</td></tr>
</tbody></table>
Hope this is useful to someone.<br />
<br />
Todo: I need to try the XFCE version of Linux Mint and Lubuntu.<br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com1tag:blogger.com,1999:blog-4051860572081872682.post-67390508548489690342013-11-25T22:53:00.000+11:002013-11-25T22:54:59.731+11:00Getting Android CMake to work....I recently wanted to get one of my libraries - <a href="http://finitetransform.sourceforge.net/">FTL</a> to build and run on my nexus 7 tablet. Since everything is done via CMake, the obvious question was could I just get the <a href="http://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a> toolchain setup and building without any changes to my library? (For those looking to setup it up manually without CMake see <a href="http://blog.jimjh.com/compiling-open-source-libraries-with-android-ndk-part-2.html">this post</a>)<br />
<br />
<b>First step.... getting Android CMake to work</b><br />
<br />
There are a number of things spread around the net but nothing conclusive to point out obvious noobie mistakes I came across.... so I documented my findings just in case someone else has the same issues:<br />
<br />
<span style="font-family: inherit;"><b>1.</b> </span>After setting up the NDK r9 x64 version as:<br />
<br />
<pre><span style="font-family: "Courier New",Courier,monospace;">export NDK=~/Dev/android-ndk-r9</span></pre>
<pre><span style="font-family: "Courier New",Courier,monospace;">$NDK/build/tools/make-standalone-toolchain.sh --platform=android-5 --install-dir=$HOME/Dev/Install/android-toolchain --toolchain=arm-linux-androideabi-4.8</span></pre>
<pre> </pre>
<span style="font-family: inherit;">It is very </span>important to put the whole path in and not the './' instead. Otherwise it will complain about the NDK install not being found. The toolchain should match your device. [From <a href="http://android-cmake.googlecode.com/hg/documentation.html">Android CMake docs</a>]<br />
<br />
<b>2.</b> Next you need Android CMake. The project on <a href="http://code.google.com/p/android-cmake/">Google Code</a> is no longer supported, but the <a href="http://code.opencv.org/projects/opencv/repository">OpenCV</a> version appears to be the latest version, so grab it from <a href="http://code.opencv.org/projects/opencv/repository/revisions/master/entry/platforms/android/android.toolchain.cmake">here</a>. You just need the .cmake file, so I grabbed the Google Code version and replaced the android.toolchain.cmake file with the latest version. I placed this at ~/Dev/Install/android-cmake.<br />
<br />
<b>3.</b> Test it on the Android CMake samples available on the <a href="http://code.google.com/p/android-cmake/source/browse/">Google Code repository</a>. Setup the environment:<br />
<span style="font-family: "Courier New",Courier,monospace;"><br /></span>
<span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;">export ANDROID_NDK=~/Dev/android-ndk-r9<br />export ANDROID_NDK_STANDALONE_TOOLCHAIN=~/Dev/Install/android-toolchain</span></span><br />
<span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;">export ANDROID_NDK_TOOLCHAINS_PATH=$ANDROID_NDK<br />export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 </span></span><br />
<span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;">export PATH=$ANDROID_NDK_STANDALONE_TOOLCHAIN/bin:$PATH</span></span><br />
<span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;">export ANDROID_CMAKE=~/Dev/Install/android-cmake<br />export ANDTOOLCHAIN=$ANDROID_CMAKE/toolchain/android.toolchain.cmake</span></span><br />
<span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;">alias android-cmake='ccmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN -DANDROID_NDK=$ANDROID_NDK -DCMAKE_C_COMPILER=arm-linux-androideabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-androideabi-g++ -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 -DANDROID_NDK_TOOLCHAINS_PATH=~/Dev/android-ndk-r9'</span></span><br />
<br />
The last 'alias' command should be on one line or break it up slashes. The tricky bit is the distinction between the <span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;">ANDROID_NDK <span style="font-family: inherit;"><span style="font-size: small;">and the </span></span></span></span><span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: inherit;"><span style="font-size: small;"><span style="font-size: xx-small;"><span style="font-family: "Courier New",Courier,monospace;">ANDROID_NDK_STANDALONE_TOOLCHAIN</span></span>. The latter is good for directly accessing the compilers etc. and the former is needed by Android CMake to find the NDK. If not set correctly, you get the "<i>Could not find any working toolchain in the NDK. Probably your Android NDK is broken</i>" message.</span></span></span></span><br />
<br />
If all goes well then doing the following will work:<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;">mkdir build</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;">cd build</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;">android-cmake ..</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;">make -j 4 </span></span><br />
<br />
At 'android-cmake' line, I used the Curses front-end for CMake. Replace it with your preferred front-end. The rest of the documentation for <a href="http://android-cmake.googlecode.com/hg/documentation.html">Hello-CMake example</a> should work fine. More on Android CMake porting of libraries later....<br />
<br />
Cheers
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-53047768602034013652010-08-15T13:18:00.004+10:002010-08-17T17:53:01.666+10:00Slices, Stacks and ITKI recently had to program some registration and decided to use <a href="http://www.itk.org/">ITK</a>. However, there are a number of things I could not find well documented, so I thought I'd put stuff I had to figure out in this post, in the hope it will be useful to others.<br />
<br />
Firstly to load a TIFF series or image stack, which is well documented in the <a href="http://www.itk.org/ITK/resources/software.html">ITK Software Guide</a> (Section 7.11), the code looks like this:<br />
<span style="color: blue; font-size: x-small;"><br />
typedef unsigned short PixelType; </span><br />
<span style="color: blue; font-size: x-small;">typedef itk::Image< PixelType, 3 > ImageStackType; </span><br />
<span style="color: blue; font-size: x-small;">typedef itk::ImageSeriesReader< ImageStackType > ReaderType;<br />
typedef itk::NumericSeriesFileNames NameGeneratorType;</span> <br />
<br />
<span style="font-size: x-small;"><span style="color: blue;">///Generate Numerical File Names</span><br style="color: blue;" /><span style="color: blue;">NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();</span><br style="color: blue;" /><span style="color: blue;"> nameGenerator->SetSeriesFormat( argv[1] );</span><br style="color: blue;" /><span style="color: blue;"> nameGenerator->SetStartIndex( first );</span><br style="color: blue;" /><span style="color: blue;"> nameGenerator->SetEndIndex( last );</span><br style="color: blue;" /><span style="color: blue;"> nameGenerator->SetIncrementIndex( 1 );</span><br style="color: blue;" /><br style="color: blue;" /><span style="color: blue;">///Read Stack as TIFFs</span><br style="color: blue;" /><span style="color: blue;">ReaderType::Pointer stackReader = ReaderType::New();</span><br style="color: blue;" /><span style="color: blue;"> stackReader->SetImageIO( itk::TIFFImageIO::New() );</span><br style="color: blue;" /><span style="color: blue;"> stackReader->SetFileNames( nameGenerator->GetFileNames() );</span><br style="color: blue;" /><span style="color: blue;"> stackReader->Update();</span></span><br />
<br />
Here argv[1] will be an sprintf format string like 'file%03d.tif' for reading files named file001.tif, file002.tif etc. The typedefs may appear to be overly used, but results in much leaner and reusable code.<br />
<br />
To view the stack, use the ImageToVTKFilter (found <a href="http://www.vtk.org/Wiki/ITK_FAQ#How_to_combine_ITK_and_VTK_in_my_application">following these intructions</a>) like:<br />
<br />
<span style="color: blue; font-size: x-small;">typedef itk::ImageToVTKImageFilter< ImageStackType > StackConnectorType; </span><br />
<br />
<span style="color: blue; font-size: x-small;">///Export to VTK<br />
StackConnectorType::Pointer stackConnector = StackConnectorType::New();<br />
stackConnector->SetInput( imageStackFiltered );<br />
stackConnector->Update();<br />
stackConnector->GetOutput()->GetExtent(bounds);<br />
cout << "Size: " << bounds[1] << "x" << bounds[3] << endl;<br />
<br />
///Display<br />
DGVImageVTK *imageStackView = new DGVImageVTK;<br />
imageStackView->alignImages(false); //Has no effect?<br />
imageStackView->setName("Image Stack");<br />
imageStackView->SetInput(stackConnector->GetOutput());<br />
imageStackView->generateImage();<br />
imageStackView->show(); </span><br />
<br />
The result of the filter is passed to my DGV Image Class which wraps VTK. You can find DGV <a href="http://qcplusplus.sourceforge.net/">here</a>. You should be able to pass the connector to vtkImageViewer2 class also.<br />
<br />
There are two main posts/email-list entries that are useful for slice traversal and processing. The <a href="http://www.itk.org/pipermail/insight-users/2009-June/030906.html">first is the method</a> using itk::PasteImageFilter. I found this to work but contained large amounts of code and was very slow.<br />
<br />
The <a href="http://www.itk.org/pipermail/insight-users/2009-May/030193.html">second method</a> was the JoinSeriesImageFilter, which a lot better but missed some newbie ITK stuff, which I missed and resulted in all slices of the result containing the same slice. The end working result is code that looks like:<br />
<div style="color: blue;"><span style="font-size: x-small;"><br />
</span></div><div style="color: blue;"><span style="font-size: x-small;">///Iterators<br />
typedef itk::ImageSliceConstIteratorWithIndex< ImageStackType > SliceConstIteratorType;</span></div><div style="color: blue;"><span style="font-size: x-small;">///Extractors</span></div><div style="color: blue;"><span style="font-size: x-small;">typedef itk::ExtractImageFilter< ImageStackType, ImageType > ExtractFilterType;<br />
typedef itk::JoinSeriesImageFilter< ImageType, ImageStackType > JoinSeriesFilterType;</span></div><div style="color: blue;"><span style="font-size: x-small;"><br />
</span></div><div style="color: blue;"><span style="font-size: x-small;">///Traverse through slices and produce new output stack<br />
///Setup Slice Iterators which will iterate through slices in the stack<br />
SliceConstIteratorType inIterator( imageStackFiltered, imageStackFiltered->GetLargestPossibleRegion() );<br />
inIterator.SetFirstDirection( 0 ); ///x axis<br />
inIterator.SetSecondDirection( 1 ); ///y axis<br />
<br />
///Setup Image Stack that will be Joined together<br />
JoinSeriesFilterType::Pointer joinSeries = JoinSeriesFilterType::New();<br />
joinSeries->SetOrigin( imageStackFiltered->GetOrigin()[2] );<br />
joinSeries->SetSpacing( imageStackFiltered->GetSpacing()[2] );</span></div><div style="color: blue;"><span style="font-size: x-small;"><br />
</span></div><span style="color: blue; font-size: x-small;">for(inIterator.GoToBegin(); !inIterator.IsAtEnd(); inIterator.NextSlice())<br />
{<br />
//cout << inIterator.GetIndex() << endl;<br />
<br />
///Setup region of the slice to extract<br />
ImageStackType::IndexType sliceIndex = inIterator.GetIndex();<br />
ExtractFilterType::InputImageRegionType::SizeType sliceSize = inIterator.GetRegion().GetSize();<br />
sliceSize[2] = 0;<br />
ExtractFilterType::InputImageRegionType sliceRegion = inIterator.GetRegion();<br />
sliceRegion.SetSize( sliceSize );<br />
sliceRegion.SetIndex( sliceIndex );<br />
<br />
///Pull out slice<br />
ExtractFilterType::Pointer inExtractor = ExtractFilterType::New(); ///Must be within loop so that smart pointer is unique<br />
inExtractor->SetInput( imageStackFiltered );<br />
inExtractor->SetExtractionRegion( sliceRegion );<br />
inExtractor->Update();<br />
<br />
///Operate on Slice<br />
InvertorType::Pointer invertor2 = InvertorType::New(); ///Must be within loop so that smart pointer is unique<br />
invertor2->SetInput( inExtractor->GetOutput() );<br />
invertor2->Update();<br />
<br />
///Save Slice<br />
joinSeries->PushBackInput( invertor2->GetOutput() );<br />
}<br />
<br />
///----------<br />
///Write out multi-page TIFF of the result<br />
joinSeries->Update();<br />
WriterType::Pointer writer = WriterType::New();<br />
writer->SetFileName( "registered_stack.tif" );<br />
writer->SetInput( joinSeries->GetOutput() );<br />
<br />
try<br />
{<br />
writer->Update();<br />
}<br />
catch( itk::ExceptionObject & err )<br />
{<br />
std::cerr << "Write Output Exception caught !" << std::endl;<br />
std::cerr << err << std::endl;<br />
return EXIT_FAILURE;<br />
}</span><br />
<br />
The iterator goes through all slices without needing to know anything about dimensions or sizes. You will have to tell the ExtractFilter the slice to extract, this is described using ImageRegions.<br />
<br />
The operation applied to the slices is simply an inversion of the greyscales, especially useful if the slices are negative images. Note that the pointers are declared within the loop, this is important because the pointers remain valid only within the loop and automatically deleted since we are using SmartPointer's. The effect is that ExtractFilter then points correctly to the current slice. The result is written as a multi-page TIFF file, which you can open in ImageJ etc.<br />
<br />
The above operation was used as a test, which will be replaced by registration code. If you are applying filters slice by slice, look into the SliceBySliceImageFilter that can be found in the Code/Review branch of ITK atm. To invert greyscales and then rescale intensities on each slice, you get:<br />
<br />
<div style="color: blue;"><span style="font-size: x-small;">typedef itk::InvertIntensityImageFilter< ImageType > InvertorType;<br />
typedef itk::RescaleIntensityImageFilter< ImageType > RescaleIntensityType; </span></div><div style="color: blue;"><span style="font-size: x-small;">typedef itk::SliceBySliceImageFilter< ImageStackType, ImageStackType, InvertorType, RescaleIntensityType > SliceFilterType;</span></div><div style="color: blue;"><span style="font-size: x-small;"><br />
</span></div><span style="color: blue; font-size: x-small;">///Filter Stack<br />
InvertorType::Pointer invertor = InvertorType::New(); ///Invert Greyscales<br />
RescaleIntensityType::Pointer rescaler = RescaleIntensityType::New(); ///Normalise image values<br />
rescaler->SetOutputMinimum( 0 );<br />
rescaler->SetOutputMaximum( ImageMax );<br />
rescaler->SetInput( invertor->GetOutput() );<br />
<br />
///Apply the filters to each slice of the stack<br />
SliceFilterType::Pointer sliceFilter = SliceFilterType::New();<br />
sliceFilter->SetInput( 0, imageStack );<br />
sliceFilter->SetInput( 1, imageStack );<br />
sliceFilter->SetInputFilter( invertor );<br />
sliceFilter->SetOutputFilter( rescaler );<br />
sliceFilter->Update();</span><br />
<br />
Thats it for the moment. More on registration later and code release later.<br />
<br />
Hope that helps.<br />
Cheers Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com2tag:blogger.com,1999:blog-4051860572081872682.post-34081194851668387072010-06-19T00:05:00.001+10:002010-06-19T00:06:07.412+10:00Packaging Qt Applications for Ubuntu/DebianI have recently attempted to get my Discrete Geometry 3D Viewer capable of building Debian packages, so that one may install DGV without needing to compile it or worry about dependencies for other Ubuntu Distros (like the <a href="http://groups.google.com/group/discrete-geometry-viewer/browse_thread/thread/bdf4c53a50d19d1b/3b4802905476e08d#3b4802905476e08d">question</a> I got from a potential user). <br />
<br />
I believed there would be a substantial discussion on how to do this for Qt applications, but I could only find the <a href="http://wiki.maemo.org/Packaging_a_Qt_application">Maemo Guide</a> useful. It gets even more difficult if you want to do multiple binaries from a single source. Hence, I have documented my findings of this topic in this blog.<br />
<br />
Useful Links that I used:<br />
<a href="https://wiki.ubuntu.com/PackagingGuide/Complete">Complete Ubuntu Packaging Guide</a><br />
<a href="http://wiki.maemo.org/Packaging_a_Qt_application">Qt App Maemo Guide</a><br />
<a href="https://help.ubuntu.com/community/GnuPrivacyGuardHowto">GPG Guide</a><br />
<a href="https://wiki.ubuntu.com/PbuilderHowto">Pbuilder Howto</a><br />
<a href="http://wiki.debian.org/PbuilderTricks#Howtoincludelocalpackagesinthebuild">Using Local Packages </a><br />
<br />
Firstly, my situation is the following. I have three side-by-side dynamic libraries, dgv-base, dgv-contrib and dgv-vtk. The libraries are divided based on dependencies of Qt, None, and dgv-base & Qt & VTK respectively by design. Then there's the actual DGV application which depend on these libraries.<br />
<br />
First the multiple libraries. Begin by renaming the source directory, with the name of the package and the version (with a dash as the separator, this is important). For example<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>libdgv-0.15
</code></pre><br />
Assuming that your source is in the state you wish to distribute it, create the tarballs so that you have two tarballs<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>libdgv-0.15.tar.gz
libdgv_0.15.orig.tar.gz
</code></pre>Note the underscore between the library name and the version. This is very important.<br />
<br />
Change to the directory of the source and execute<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>dh_make -e your.maintainer@address -c GPL
</code></pre>where the "-c GPL" assumes you are using GPLv3 license and "your.maintainer@address" is your email address. This will ask you a series of questions, where you should select library if you're doing a library or a single binary if you're doing a binary. I will assume a library for the aforementioned reasons.<br />
<br />
This step will create a directory called "debian" with all the Debian package configuration files. Remove the example files, they are not needed for what we are doing as far as I know.<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>rm *.ex *.EX
</code></pre>Please read these pages of the <a href="https://wiki.ubuntu.com/PackagingGuide/Complete#changelog">packaging guide</a> for the remaining files. You need to edit the control and rules files as <a href="http://code.google.com/p/discrete-geometry-viewer/wiki/DebianPkg">I have for DGV</a> (also see <a href="http://wiki.maemo.org/Packaging_a_Qt_application">Maemo guide</a> for a simple single binary example). Things to watch out for is also given in this <a href="http://code.google.com/p/discrete-geometry-viewer/wiki/DebianPkg">link</a> (at the end). Fill the changelog and copyright files as described by the package guide, making sure to use the name of the overall package where applicable and to match the author email to your GPG name. If you do not have one, you need to create one using the <a href="https://help.ubuntu.com/community/GnuPrivacyGuardHowto#Using%20GnuPG%20to%20generate%20a%20key">GPG guide</a> to sign your packages.<br />
<br />
For multiple binaries, there is one last step. You need to create the ".install" and ".dir" file for each package. The former has the list of files to be installed, but in a wild card format (e.g. "usr/lib/lib*.so"). The latter is where the files are to be installed (e.g. "usr/lib").Note that there is no "/" in front as per normal Linux directories from root. This is because they will be relative paths and when the real package is built, it will build it from the root. See the debian files I created for DGV <a href="http://qcplusplus.svn.sourceforge.net/viewvc/qcplusplus/dgv/debian.tar.gz?revision=64">here</a>.<br />
<br />
Now to build your package, we will use <a href="https://wiki.ubuntu.com/PbuilderHowto">Personal Builder (pbuilder)</a>, a way to build your package using only the minimal (initial) Ubuntu base/setup plus your dependencies. This is the best part that makes constructing packages most useful. If your dependencies are correct, then the user just installs the package and Synaptic or apt-get just installs everything you need to get it going. Once a pbuilder environment is setup (which can be made to suit for building on different architectures and Ubuntu distros), the package is built with your configuration and placed into<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>/var/cache/pbuilder/result
</code></pre>Only downside is that all the base packages will be downloaded from the Ubuntu repository, which could take a while. If you can't use the Internet for whatever reason, you can still build it the packages using<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>debuild</code></pre>when within the source directory. You might also want to do this initially to ensure that its all working correctly.<br />
<br />
First create the pbuilder environment by<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>sudo pbuilder create --distribution $(lsb_release -cs) \
--othermirror "deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted universe multiverse"
</code></pre>Then build the descriptor file<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>debuild -S
</code></pre>If you did a "debuild" already, then this step is unnecessary. Once the descriptor file is present, then build using pbuilder<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>sudo pbuilder build *.dsc
</code></pre>To build as a different distro or architecture, see <a href="https://wiki.ubuntu.com/PbuilderHowto#Building%2032-bit%20packages%20on%2064-bit%20or%20for%20older%20Ubuntu%20versions">this</a>. Hopefully, all works fine and you get a few packages. There might be a few warning from Lintian. Ensure that the descriptions lines are not too long or google the lintian warning. If your warning says "empty-binary-package" then your files are installed in the wrong places. For Qt projections, I install the files of the library into "debian/tmp", then move it out into the relevant package directories by using "<span class="pln">dh_movefiles </span><span class="pun">-</span><span class="pln">p$@ </span><span class="pun">-</span><span class="typ">Xcontrib</span><span class="pln"> </span><span class="pun">-</span><span class="typ">Xvtk</span><span class="pln"> usr</span><span class="pun">/</span><span class="pln">lib" command in the rules (see the <a href="http://code.google.com/p/discrete-geometry-viewer/wiki/DebianPkg">wiki</a>). The "-Xitem" tell the movefiles app to ignore the files with the string "item" from the file names.</span><br />
<br />
Finally, on a Live CD or clean install, check you packages by installing them. Pbuilder didn't pickup the fact that I had incorrectly named libvtk5.2 as libvtk5 for one of my packages, so I recommend it.<br />
<br />
I then build the dgv application and its all done. Hope this helps. I will post up more on how to use local packages later when I have it working.<br />
<br />
Cheers Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-72996455985712271602010-05-24T14:40:00.000+10:002010-05-24T14:40:14.919+10:00Doctrate Passed and New PaperI have passed my doctorate! And without any changes! A lot faster than I thought I would too. Yay! :D<br />
<br />
I have also put up my latest paper entitled "Fast Digital Convolutions using Bit-shifts". It extends the Number Theoretic Transforms (NTTs) known as Rader Transforms. You can find it on ariXiv.org <a href="http://arxiv.org/abs/1005.1497">here</a>. Hopefully it is well accepted into the scientific community.<br />
<br />
These new results will eventually end up into my <a href="http://finitetransform.sourceforge.net/">FTL/NTTW library. </a><br />
<br />
Cheers Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-22741406259297967012010-02-27T09:06:00.001+11:002010-02-27T09:07:11.439+11:00Ph.D SubmittedI have just submitted my thesis and it feels great. Its taken 3 and half years but its done! :D Still got the examination... but that's out of my hand now.<br />
<br />
Thanks to my supervisors and my colleagues.<br />
<br />
Expect to see releases for DGV and FTL libraries soon.<br />
<br />
Cheers<br />
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-72125019088042801382010-02-08T13:28:00.002+11:002010-02-08T13:29:52.037+11:00Latex/Xelatex WatermarkingI was interested in getting a watermark to display on my thesis title page, but the documentation for the packages and examples were lacking.<br />
<br />
Here's how to do it. Assuming your image is called 'ribs.png':<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\usepackage{watermark}
</code></pre>in the preamble, then the following where you want the watermark.<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>\thiswatermark{%Put watermark on this page only
%\centering
\put(0,-660){\includegraphics[width=\textwidth]{ribs}}
}
</code></pre>You use the coordinate arguments of '\put' to place it in the right position. For transparency, I just editted the image in <a href="http://www.gimp.org/">The Gimp</a> image editor. Simply go to Tools->Colour Tools->Levels and adjust the main bar.<br />
<br />
My title page looks like:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcmXpWs5cn7Dp-9HrcoyHJ8roKYQUpXnTqPZtPiNvTvKr0vzrcrM8S0QlIS2x95-j0wPRhdUoO_0LEqjAm_OMt4fh9KkDcxqWjtCVBowUvXn43QvGToPn1cqhv9Fbz9H22IzouSo6hHz4/s1600-h/title_page_crop.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcmXpWs5cn7Dp-9HrcoyHJ8roKYQUpXnTqPZtPiNvTvKr0vzrcrM8S0QlIS2x95-j0wPRhdUoO_0LEqjAm_OMt4fh9KkDcxqWjtCVBowUvXn43QvGToPn1cqhv9Fbz9H22IzouSo6hHz4/s640/title_page_crop.png" width="616" /></a></div>HTH<br />
Cheers<br />
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-68332192659047941022009-12-03T22:02:00.000+11:002009-12-03T22:02:55.802+11:00Best Poster Award - DICTA 2009Well the <a href="http://dicta2009.vu.edu.au/">DICTA conference</a>, which is "the main Australian conference on digital image processing, machine vision and related areas." is finally over. I presented my work, which is encompassed in my <a href="http://sourceforge.net/projects/finitetransform/">FTL library</a>, as a poster.<br />
<br />
The response to the work was overwhelming, and the end result was the Best Poster Award at the conference. Special thanks to my supervisor Imants Svalbe and Steve Morton for print and processing. I have added the poster to the FTL repository (so its logged). You can view it <a href="http://finitetransform.svn.sourceforge.net/viewvc/finitetransform/publications/dicta2009.pdf?revision=1">here</a>.<br />
<br />
A lot of interest was shown in the code of the work also, including from Canon Information Systems Research Australia (CISRA) personnel, hopefully it will increase its usage.<br />
<br />
Cheers<br />
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com1tag:blogger.com,1999:blog-4051860572081872682.post-90893337683139260642009-11-19T20:38:00.004+11:002009-11-20T09:33:54.067+11:00DGV 0.1 Stable ReleasedI have finally released a stable version of my <a href="http://qcplusplus.sourceforge.net/">DGV</a> software. You can grab it on <a href="http://sourceforge.net/projects/qcplusplus/files/Discrete%20Geometry%20Viewer/Stable/Version%200.1/">Sourceforge.</a><br />
You can view some tutorials at the <a href="http://code.google.com/p/discrete-geometry-viewer/wiki/Home">Google Code page</a>.<br />
<br />
<b>What's DGV for? </b>In my honours, I just wanted an easy, no fuss way to visualise my data (which was a 2D complex scalar field). To my dismay, I couldn't find one and ended up using Excel (I know.... really bad). So I wrote DGV as tool that allowed this. Most times I just wanted a tool view my data quickly. This is DGV's main goal. It has also been supplemented by my current Ph.D project on Image processing.<br />
<br />
It has so far clocked over 2000 downloads and has far exceeded all my expectations. As such, it will be supported indefinitely into the future. I will also be adding my <a href="http://finitetransform.sourceforge.net/">FTL Library</a> to it soon, which should propel the software into the forefront of state-of-the-art Convolutions. The next major release will be after I submit my Ph.D Thesis (hopefully around March next year).<br />
<br />
Note for Linux uses, the Linux build was built using the latest Ubuntu OS - Koala, so it requires the latest C++ standard libraries. In other words, it should run in any of the latest distros. This may be changed if it is found to be a major problem. <br />
<br />
Cheers<br />
Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-70077204294130563222009-08-23T13:11:00.008+10:002009-08-23T13:35:12.874+10:00Discrete Geometry 3D ViewerI thought I'd write list of features of my <a href="http://qcplusplus.sourceforge.net/">Discrete Geometry Viewer (DGV)</a> program. I wrote this as a request from the New Projects section of the Linux Journal. The goal of <a href="http://qcplusplus.sourceforge.net/">DGV</a> is to make visualisation of data as simple as possible (not something <a href="http://www.vtk.org/">VTK</a> is renowned for) while being intuitive and responsive.<br /><br />In <a href="http://qcplusplus.sourceforge.net/">DGV</a>, the image is placed into a 3D scene using OpenGL (via the <a href="http://www.vtk.org/">VTK</a> library), so it uses your graphics card to render the image. U can pan and zoom, adjust the gamma and rotate it. U can save what you're viewing or just export the data/image. U can also view the raw data in table form (may not be as useful to non-scientific users). From the table u can do surface and line plots. U can also add, subtract etc. images using the Operate feature. Finally, one can see the histogram of the image, which tells u statistical info on the image (output into console also).<br /><br />The main feature of <a href="http://qcplusplus.sourceforge.net/">DGV</a> is Filtering and Convolutions via Fast Fourier Transforms. This allows one to see the frequencies present within the image and edit them via the table. One can do crude Low-pass (smoothing), High-pass (edge detection) or band-pass filtering. DGV also features surface and line animations.<br /><br />Future advancements will include:<br />- Pixel values within viewer<br />- Saving animations<br />- Python Shell rather than simple console output. See my project called <a href="https://sourceforge.net/projects/qpythonshell/">QPythonShell</a> which allows one to embed a Python shell into Qt applications.<br />- More file formats<br />- More transforms, like the Number Theoretic Transforms (via my new <a href="http://l3mmings.blogspot.com/2009/08/nttw-number-theoretic-transform-library.html">Number Theoretic Transform C library</a>).<br /><br />Links:<br /><a href="http://qcplusplus.sourceforge.net/">Homepage</a>, <a href="http://sourceforge.net/projects/qcplusplus/">Sourceforge</a>, <a href="http://code.google.com/p/discrete-geometry-viewer/">Google Code</a> and <a href="http://www.qt-apps.org/content/show.php/Discrete+Geometry+3D+Viewer?content=95201&PHPSESSID=9bb769cd119b1cac24c6f8bf9cdde5e8"></a><a href="http://www.qt-apps.org/content/show.php/Discrete+Geometry+3D+Viewer?content=95201&PHPSESSID=9bb769cd119b1cac24c6f8bf9cdde5e8">Qt Apps.org</a>.<br /><br />Cheers<br />Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-60547667507072608102009-08-15T21:28:00.005+10:002009-08-15T21:38:16.176+10:00NTTW - The Number Theoretic Transform LibraryI have just released my Number Theoretic Transforms (NTT) C library under GPL v3. I've called it <a href="http://code.google.com/p/finite-transform-library/">NTTW</a> to match FFTW, a well known Discrete Fourier Transform library. It's functions compute the NTTs using Cooley-Tukey's Fast algorithm. The current release only has dyadic length functions. Prime length functions will be released after I submit a journal paper I've been working on.<br /><br />NTTW is to be part of a larger library called <a href="http://code.google.com/p/finite-transform-library/">Finite Transform Library (FTL)</a>. You can call it Faster Than Light too. :P This new library will feature other transforms I've been working on in my Ph.D, as well as incorporating FFTW. More news later as I complete papers and libraries.<br /><br />Cheers<br />Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com2tag:blogger.com,1999:blog-4051860572081872682.post-9551332043907848362009-08-06T16:57:00.014+10:002009-08-06T17:44:29.521+10:00XeLaTeX 1,2,3...I thought I'd explain how to get started with Xelatex as a three step process.<br /><br /><span style="font-weight: bold;">Firstly though..... why Xelatex?</span><br /><ol><li>For arbitrary text and maths fonts in your document.</li><li>Correct ligatures, kerning and other font features. This is only achieved in Latex using the microtype package, it is the default in Xelatex. See <a href="http://nitens.org/taraborelli/latex">Beauty of Latex</a> article.<br /></li><li>Easier to use arbitrary fonts.</li><li>Unicode (UTF-8) encoding for special characters like international accents etc.<br /></li></ol><span style="font-weight: bold;">Step 1: Installing and Using Xelatex</span><span style="font-style: italic;"><br />Windows</span>: Xelatex can be found in <a href="http://miktex.org/">Miktex</a> 2.7 or above. Simply <a href="http://miktex.org/2.7/setup">download</a> and install Miktex Basic and install the xelatex package from the package manager. If any package is needed later on, Miktex will download and install it for you.<br /><span style="font-style: italic;">Linux</span>: Install <a href="http://www.tug.org/texlive/">Texlive</a> 2008 or above. Note that all versions of Ubuntu 9.04 and earlier have Texlive 2007. <a href="http://www.tug.org/texlive/acquire.html">Download the Installer or the ISO file</a>, burn the disc and run the install script ("install-tl"). See <a href="http://www.tug.org/texlive/quickinstall.html">Texlive site</a> for more detailed instructions. Go <a href="http://texblog.net/latex-archive/linux/kile-texlive-2008-equivs/">here</a> to use Kile with Ubuntu after installing Texlive 2008.<br /><br /><span style="font-weight: bold;">Step 2: Using Xelatex</span><br />Using Xelatex is the same as using Latex. New to Latex? See this <a href="http://ctan.unsw.edu.au/info/lshort/english/lshort.pdf">all you need guide</a>. Create a new file and insert the following text into it.<br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code>%!TEX TS-program = xelatex<br />%!TEX encoding = UTF-8 Unicode<br />\documentclass[a4paper]{article}<br /><br />%XeLaTeX packages<br />\usepackage{xltxtra}<br />\usepackage{fontspec} %Font package<br />\usepackage{xunicode}<br /><br />\title{Your Title}<br />\author{Your Name}<br />\date{\today}<br /><br />\begin{document}<br /><br />\maketitle<br /><br />\section{Section Title}<br />Your text<br /><br />\subsection{Subsection Title}<br />Your Text<br />\end{document}<br /></code></pre>Save the file with any name. Then using the command line type "xelatex [FileName]<filename\><file><your>.tex" where you file is, or in a text editor like <a href="http://scintilla.sourceforge.net/index.html">SciTE</a> or <a href="http://www.xm1math.net/texmaker/">Texmaker</a> click on the build button. Open and view the PDF file to see the result.<br /><br /><span style="font-weight: bold;">Step 3: Installing and Changing the Font</span><br />Changing the font is easy in Xelatex, just add the line "\setmainfont[Mapping=tex-text]{Fontname<span>}" in your preamble (the space before the begin document line) with "Fontname" <span> being the name of the Font. Any font installed on your system is applicable. See my post on <a href="http://l3mmings.blogspot.com/2009/07/xelatex-thesis-choices.html">Xelatex Thesis Choices</a> for example of using Minion Pro fonts. For instance "Times New Roman" is comon on most systems. Use can see the fonts installed on your system using OpenOffice or any other font application.<br />Installing a font is easy too. Find and download a font you like (the hard part), see my <a href="http://l3mmings.blogspot.com/2009/07/font-survey.html">font survey post</a> to get some free and open ones, and extract if in archive.<br /><span style="font-style: italic;">Windows Vista</span>: Right click on the TrueType (ttf) file(s) or OpenType (otf) file(s). Then select install. Thats it! To determine the name of the font, either look for it in OpenOffice, Wordpad or MS Office. Or double click to preview and the name is given in the preview.<br /><span style="font-style: italic;">Ubuntu Linux</span>: Copy the TrueType (ttf) file(s) or OpenType (otf) file(s) to "/usr/share/fonts/opentype". If there is no opentype directory, create it.<br /><br />That's it... you're good to go. Post any questions below.<br /><br />Cheers<br />Shakes - L3mming</span></span></your></file></filename\>Shakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0tag:blogger.com,1999:blog-4051860572081872682.post-67866523669700112052009-08-01T07:10:00.006+10:002009-08-02T17:09:59.290+10:00Thesis Font: BaskervilleHaving asked the opinions of some of my colleagues and my family (who are now quite sure I'm obsessed about fonts :D ) about the font choices, I have finally made the font choice for my thesis - Baskerville (or its open equivalent, see <a href="http://arkandis.tuxfamily.org/docs/Baskervald-Cat.pdf">a sample</a>).<br /><br />The font has a great history starting from its inception in 1757, which makes it perfect for the type of I'm going for - a Classic font. Wikipedia says:<br /><p><b></b></p><blockquote><p><b>Baskerville</b> is a transitional <a href="http://en.wikipedia.org/wiki/Serif" title="Serif">serif</a> <a href="http://en.wikipedia.org/wiki/Typeface" title="Typeface">typeface</a> designed in 1757 by <a href="http://en.wikipedia.org/wiki/John_Baskerville" title="John Baskerville">John Baskerville</a> (1706-1775) in <a href="http://en.wikipedia.org/wiki/Birmingham" title="Birmingham">Birmingham</a>, <a href="http://en.wikipedia.org/wiki/England" title="England">England</a>. Baskerville is classified as a <a href="http://en.wikipedia.org/wiki/Transition" title="Transition">transitional</a> typeface, positioned between the old style typefaces of <a href="http://en.wikipedia.org/wiki/William_Caslon" title="William Caslon">William Caslon</a>, and the modern styles of <a href="http://en.wikipedia.org/wiki/Giambattista_Bodoni" title="Giambattista Bodoni">Giambattista Bodoni</a> and <a href="http://en.wikipedia.org/wiki/Firmin_Didot" title="Firmin Didot">Firmin Didot</a>.</p> <p>The Baskerville typeface is the result of John Baskerville's intent to improve upon the types of William Caslon. He increased the contrast between thick and thin strokes, making the serifs sharper and more tapered, and shifted the axis of rounded letters to a more vertical position. The curved strokes are more circular in shape, and the characters became more regular. These changes created a greater consistency in size and form.</p> <p>Baskerville's typeface was the culmination of a larger series of experiments to improve legibility which also included paper making and ink manufacturing. The result was a typeface that reflected Baskerville's ideals of perfection, where he chose simplicity and quiet refinement. His background as a writing master is evident in the distinctive swash tail on the uppercase <b>Q</b> and in the cursive serifs in the Baskerville Italic. The refined feeling of the typeface makes it an excellent choice to convey dignity and tradition.</p></blockquote><p></p><blockquote><p></p></blockquote><p></p>The open alternatives include <a href="http://arkandis.tuxfamily.org/adffonts.html">Baskervald from ADF Fonts</a>, <a href="http://www.greekfontsociety.gr/pages/en_typefaces18th.html">GFS Baskerville</a> from Greek Font Society (which is Greek only, still good from Physicists/Mathematicians though. Map it to the XeLaTeX Greek fonts), <a href="http://klepas.org/openbaskerville/">Open Baskerville</a> (UFO Font only.... don't know how to get to Opentype yet) and <a href="http://mitek.webpark.cz/boisik/">Boisk Font</a> which is inspired by Baskerville. I will add more as I find them.<br /><br />Cheers<br />Shakes - L3mmingShakeshttp://www.blogger.com/profile/07174706445561277789noreply@blogger.com0