User talk:Andy

From KitwarePublic
Revision as of 20:47, 17 November 2004 by Andy (talk | contribs) (→‎ITK Filter)
Jump to navigationJump to search

VIM is a great editor

Ok, so I use VIM. I used to use Emacs, but I guess the starting time was bothering me. Also, for small sysadmin edits I used VIM already and I was mixing key strokes from Emacs and VIM.


My VIM Settings

set nocompatible " We use a vim
set noautoindent
set tabstop=2       " Tabs are two characters
set shiftwidth=2    " Indents are two charactes too
set expandtab       " Do not use tabs

syntax on           " Turn on syntax hilighting

set hlsearch        " Hilight the search results
set incsearch       " Incrementally search. Like Emacs

set autochdir       " Automatically chdir to directory of the buffer
set matchpairs+=<:>
"set matchpairs+=<:> 
set showmatch
set laststatus=2
set guioptions-=T
set guioptions-=m
set guioptions+=f
"set guifont=Fixed\ 11
"set guifont=Fixed\ 11
set viminfo+=n$HOME/.vim/viminfo
"set guifont=-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*
"set guifont=Andale\ Mono\ 8

colorscheme darkblue

amenu F&ont.&5x7            :set guifont=5x7<CR><C-L>
amenu F&ont.&6x10           :set guifont=6x10<CR><C-L>
amenu F&ont.6x13            :set guifont=6x13<CR><C-L>
amenu F&ont.&7x13           :set guifont=7x13<CR><C-L>
amenu F&ont.&8x13           :set guifont=8x13<CR><C-L>
amenu F&ont.&9x15           :set guifont=9x15<CR><C-L>
amenu F&ont.&10x20          :set guifont=10x20<CR><C-L>
amenu F&ont.&12x24          :set guifont=12x24<CR><C-L>
amenu F&ont.&heabfix        :set guifont=-*-haebfix-medium-r-normal-*-15-*-*-*-*-*-*-*<CR><C-L>
amenu F&ont.&lucida         :set guifont=-*-lucidatypewriter-medium-r-*-*-14-*-*-*-*-*-*-*<CR><C-L>



if exists("loaded_vimspell")
  set spell_auto_type="tex,mail,text,html,sgml,otl"
  :SpellAutoEnable
endif

set wildmode=longest " Make tabcompletion behave correctly
set selection=exclusive "  Only select up to not including last character
set ignorecase " Ignore case when searching lowercase
set smartcase " Ignore case when searching lowercase


set cinoptions={1s,:0,l1,g0,c0,(0,(s,m1
highlight SpellErrors guibg=Red guifg=Black
:autocmd BufRead,BufNewFile [Mm]akefile :set noexpandtab
highlight SpellErrors  guibg=Red guifg=Black

Random things that need to be put somewhere

Random Python Tricks

How do I get a current line number or file name from the scrip?

import inspect

f = inspect.currentframe()
print "Line number: %d" % f.f_lineno
print "File name: %s" % f.f_code.co_filename

Also, you can go up the stack and do the same thing:

lineno = inspect.currentframe().f_back.f_lineno

CVS branch control

Note: this script accesses the Entries file directly, it has already pointed out that it should be upgraded to use the cvs status command to be independent of Entries file format changes in the future.

ITK Filter

The first ITK filter you may want to look at is the UnaryFunctorImageFilter.

http://www.itk.org/Insight/Doxygen/html/classitk_1_1UnaryFunctorImageFilter.html

It is in

           Insight/Code/BasicFilters


This filter takes one image as input and produces another image as output. The processing is done pixel by pixel, meaning that the pixel at the output is computed only from the corresponding (i,j) pixel in the input.

The filter uses the input and output images types as template parameters, and a third template parameter is a "Functor" class that indicates what operation must be performed in the input pixel in order to compute the output pixel.

The functor is usually written in about 10 lines of code, and with them you can instantiate a specialization of the UnaryFunctorFilter.

An example on how to instantiate this filter is in the Sinus Image Filter, ( a filter that computes

           OutputPixel = sin( InputPixel)

http://www.itk.org/Insight/Doxygen/html/classitk_1_1SinImageFilter.html

The code is in


         Insight/Code/BasicFilters/


In 30 lines of code, it implements the full filter by deriving from an instantiation of the Unary Functor filter.



Homework:

  Create a pixel wise filter that will set to 0 all the
  pixels of an image with values below 100.


Hint:

    Do not look at the BinaryThresholdImageFilter.

http://www.itk.org/Insight/Doxygen/html/classitk_1_1BinaryThresholdImageFilter.html


The second filter you want to look at is the BinaryFunctorImageFilter. http://www.itk.org/Insight/Doxygen/html/classitk_1_1BinaryFunctorImageFilter.html

This filter is very similar to the UnaryFunctorImageFilter of Lesson 1, but it accepts two input images and produces one output image. The Functor mechanism is also used here, so a new filter is created by first writing its corresponding Functor that tells how to compute the output pixel value from the pixel values of the two input image pixels.

    OuputValue = Functor(  InputPixelA , InputPixelB )

For an example of an instantiation of this filter you can look at the AddImageFilter

http://www.itk.org/Insight/Doxygen/html/classitk_1_1AddImageFilter.html

The code is in

           Insight/Code/BasicFilters



Homework:

   Create a MaskImageFilter using the BinaryFunctorImageFilter


Hint:

   Do not look at the MaskImageFilter

http://www.itk.org/Insight/Doxygen/html/classitk_1_1MaskImageFilter.html


You can now look a the neighborhood filters. Those are filters that compute the output pixel value based on a neighborhood of the input pixel value.

The value is computed by applying an "Operator" to the input neighborhood. The basic filter for this purpose is the NeighborhoodOperatorImageFilter http://www.itk.org/Insight/Doxygen/html/classitk_1_1NeighborhoodOperatorImageFilter.html

This filter is used internally in the DerivativeImageFilter http://www.itk.org/Insight/Doxygen/html/classitk_1_1DerivativeImageFilter.html


Note that it is instantiated internally and used for delegating the computation of the output image.


Very close to this filter is the MeanImageFilter http://www.itk.org/Insight/Doxygen/html/classitk_1_1MeanImageFilter.html

It is a good filter to look at the use of the Neighborhood iterators.



Homework:

   Write a filter that computes the value of the output pixel
   by voting among the input pixels. The votes are for value 0
   if the input pixel in the neigborhood is < a threshod, and
   the votes will be for 255 if the input pixel in the neighborhood
   is >= (the same threshold).


Hint:

   Don't look at the BinaryMedianImageFilter

http://www.itk.org/Insight/Doxygen/html/classitk_1_1BinaryMedianImageFilter.html




The Insight Consortium declines any reponsability for stimulating your addiction to coffee.