2009年4月1日星期三

[转]在ubuntu中使用ITK的方法

老外的文章,讲得很详细,方法很简单,但没有手册,就很麻烦。

Using ITK in Ubuntu GNU/Linux

http://www.robots.ox.ac.uk/~rcasero/wiki/index.php/Using_ITK_in_Ubuntu_GNU/Linux

Introduction

These are my notes as I learn how to use ITK in Ubuntu GNU/Linux, version 8.10 (Intrepid Ibex).

The Insight Segmentation and Registration Toolkit (ITK) is "an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis".

Implementation details: "ITK is implemented in C++. ITK is cross-platform, using the CMake build environment to manage the configuration process. In addition, an automated wrapping process generates interfaces between C++ and interpreted programming languages such as Tcl, Java, and Python (using CableSwig)."

Licence: "ITK is copyrighted by the Insight Software Consortium, a non-profit alliance of organizations and individuals interested in supporting ITK. The software is distributed as open source under the OSI-approved BSD license."

Note that there's a closed source project also called ITK, and in the same field: Image Registration Toolkit (ITK). But these notes document the Insight Segmentation and Registration Toolkit, and that's what I'll refer to by ITK unless otherwise specified.

Resources:

Installation

Ubuntu has the following packages available:

$ sudo apt-get install cmake insighttoolkit3-examples libfftw3-dev libinsighttoolkit3-dev \
libinsighttoolkit3.6 python-insighttoolkit3 tcl8.4 tcl8.4-insighttoolkit3 \
tk8.4

ITK files are installed in

$ find /usr/ -iname "*insight*"
/usr/share/tcltk/tcl8.4/insighttoolkit3
/usr/share/doc/insighttoolkit3-examples
/usr/share/doc/libinsighttoolkit3.6
/usr/share/doc/libinsighttoolkit3.6/InsightLogo.gif
/usr/share/doc/tcl8.4-insighttoolkit3
/usr/share/doc/libinsighttoolkit3-dev
/usr/share/doc/libinsighttoolkit3-dev/InsightDeveloperStart.doc.gz
/usr/share/doc/libinsighttoolkit3-dev/InsightDeveloperStart.pdf.gz
/usr/share/doc/python-insighttoolkit3
/usr/share/python-support/python-insighttoolkit3
/usr/share/python-support/python-insighttoolkit3/InsightToolkit.py
/usr/share/man/man3/insighttoolkit.3.gz
/usr/share/lintian/overrides/libinsighttoolkit3.6
/usr/share/lintian/overrides/tcl8.4-insighttoolkit3
/usr/share/lintian/overrides/python-insighttoolkit3
/usr/include/InsightToolkit
/usr/lib/python-support/python-insighttoolkit3
/usr/lib/InsightToolkit

Probably the most interesting directory for the moment is the directory of the header files

$ ls /usr/include/InsightToolkit
Algorithms Common IO Numerics Utilities
BasicFilters gdcm itkConfigure.h SpatialObject

You also need to have a C++ compiler

$ sudo apt-get install g++

I was trying to compile some legacy code from Martin Bishop (i.e running 'make' after creating the Makefile with 'cmake'), and some libraries are required. I don't know whether this is a dependency of ITK in general, or Martin's code only. The libraries can be installed using (note that you need the development packages)

$ sudo apt-get install libpng12-dev libtiff4-dev

First example

The HelloWorld files of the example in section "2.1.1. Hello World!" of the ITK guide are in

$ ls /usr/share/doc/insighttoolkit3-examples/examples/Installation
CMakeLists.txt HelloWorld.cxx

Create a directory for the example and change directory to it

$ mkdir itk-helloworld
$ cd itk-helloworld

Copy the example files to your current directory

$ cp /usr/share/doc/insighttoolkit3-examples/examples/Installation/* .

Create a directory to generate the binaries and go to it

$ mkdir bin
$ cd bin

Now start CMake in order to create the Makefile

$ ccmake ..

This will show a console interface. Press 'c' to configure, and then 'g' to generate the Makefile. Now you should have

$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake Makefile

Now compile the project

$ make
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 2.6)

should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/ramc/secure_data/comlab/ramc/rcasero/software-projects/itk-helloworld/trunk/bin
Scanning dependencies of target HelloWorld
[100%] Building CXX object CMakeFiles/HelloWorld.dir/HelloWorld.o
Linking CXX executable HelloWorld
[100%] Built target HelloWorld

Now you should have

$ ls
CMakeCache.txt CMakeFiles cmake_install.cmake HelloWorld Makefile

(note the new binary HelloWorld). Run the binary to check that it works

$ ./HelloWorld
ITK Hello World !

[转]男人可能是弱势群体?

sciencedaily上的文章。
希望女同志照顾一下。
http://www.sciencedaily.com/releases/2009/03/090331112729.htm

Nurses in the maternity ward often say that a difficult labor is a sign of a baby boy. Now, researchers at Tel Aviv University claim that a new study provides scientific evidence that a male baby comes with a bigger package of associated risks than his female counterparts.

In a study of 66,000 births, Prof. Marek Glezerman, chairman of the Department of Obstetrics and Gynecology at the Sackler School of Medicine, Tel Aviv University, together with Dr. Yariv Yogev and Dr. Nir Melamed, found that while girls were at a higher risk for restricted growth in utero and for breech presentation at birth, risks associated with boy fetuses were more abundant.

"Pregnancies with a male fetus are more often complicated," says Prof. Glezerman. "They're more likely to result in a premature rupture of the embryonic sac and suffer from premature delivery. And those male fetuses which make it to term," he continues, "are more likely to suffer from excessive growth in the uterus, making delivery more difficult and leading to more cesarian section deliveries."

Study Helps Doctors See the Bigger Picture

In a study presented to the Israel Society for Gender Based Medicine, researchers concluded that male fetuses come with "a higher association of risks," but note that the findings should be viewed in the proper light. "Boys are riskier to an extent," says Prof. Glezerman, but pregnancies involving boys should not be classified as "high-risk" for that reason alone. It's only one factor for doctors to consider when looking at the whole picture, he says.

"But in general, boys are more vulnerable in their life in utero, and this vulnerability continues to exist throughout their lives," says Prof. Glezerman, an expert in gender-based medicine. "Men are known to have a shorter lifespan, are more susceptible to infections, and have less chance of withstanding disease than women. In short, men are the weaker sex."

This new evidence, Prof. Glezerman notes, confirms the old wives' tale that boy fetuses are more troublesome in the womb and the delivery room. Prof. Glezerman also takes the notion one step further. "This research not only confirms an old wives' tale, but adds to what we know about the male gender. Males are also associated with higher risk in the neonatal period after birth, and are more likely to expose themselves to risky behavior later in life."

Good Reasons for Associated Risks

Boys may take more risks as the result of peer pressure, and the presence of testosterone in a boy's bloodstream could also lead to more dangerous behavior. But this is not necessarily a bad thing, Prof. Glezerman believes. "Men become soldiers, construction workers, and work as firefighters," he notes. "They take on these risks quite naturally to protect their society, and they're trained to do this without question."

In Israel, Prof. Glezerman is chairman of the Helen Schneider Women's Hospital, and deputy director of the Rabin Medical Center, where the recent study was conducted. He also founded the Israeli Society for Gender Based Medicine and has done foundational work in support of a gender-based approach to medicine. Prof. Glezerman suggests that a new view of the role of gender in medicine is needed in all fields — internal medicine, gastroenterology, orthopedics, cardiology, and many others.

"It's almost like males and females are a different species," he says. "They complete and complement each other, but a 'one-size fits all' medical approach does an injustice to both males and females. Men and women are different in so many respects, and these differences are more significant than the similarities between them."

2009年3月16日星期一

删除注释的方法

sed -i '/^[ \t]*\%/d' test2.m
matlab程序,删除了%后面的注释
C++程序类似

参考:
http://haoxiai.net/wangzhanjianshe/zhujiyumingyouju/63901.html