Skip to content
Snippets Groups Projects
Commit 4716f0e6 authored by valerio's avatar valerio
Browse files

Work on img.alg docs and bundle scripts

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2409 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 3d6d962a
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,9 @@ print 'Copy Qt 4 plugins into package directory structure'
subprocess.call('cp -pRL '+qt4_plugins+' '+directory_name+'/bin/',shell=True,cwd='../../')
print 'Installing OpenStructure into package directory structure'
subprocess.call('make install',shell=True,cwd='../../')
print 'Copy examples into package directory structure'
print 'Copying supplementary material into package directory structure'
subprocess.call('cp -pRL stage/share/openstructure '+directory_name+'/share/',shell=True,cwd='../../')
print 'Copying examples into package directory structure'
subprocess.call('cp -pRL examples '+directory_name+'/share/openstructure/',shell=True,cwd='../../')
print 'Removing headers from package directory structure'
subprocess.call('rm -fr '+directory_name+'/include',shell=True,cwd='../../')
......
......@@ -117,6 +117,8 @@ print 'Copy examples into package directory structure'
subprocess.call('cp -pRL examples '+directory_name+'/share/openstructure/',shell=True,cwd='../../')
print 'Removing headers from package directory structure'
subprocess.call('rm -fr '+directory_name+'/include',shell=True,cwd='../../')
print 'Copying supplementary material into package directory structure'
subprocess.call('cp -pRL stage/share/openstructure '+directory_name+'/share/',shell=True,cwd='../../')
print 'Copy qmean examples into package directory structure'
subprocess.call('cp -pRL modules/scratch/qmean/examples '+directory_name+'',shell=True,cwd='../../')
print 'Copy readme and license files into package directory structure'
......
......@@ -4,6 +4,103 @@
.. module:: ost.img.alg
:synopsis: Image processing algorithms
Applying algorithms
-------------------
While image properties are usually manipulated using method of the :class:'~ost.img.ImageHandle` class, their data content
is manipulated using image algorithms. Image algorithms are objects. Each of them is a class, and its methods are used to handle the algorithm parameters. Applying an algorithm to an image is then conceptually a two-step process. First, an instance of an algorithm class is created, yielding an algorithm object. In a second step, the algorithm object is applied to an image. An algorithm can be applied in-place (using the :meth:`ost.img.ImageHandle.Apply` method), modifying the image. or out-of-place, (using :meth:`~ost.img.ImageHandle.ApplyIP` ), leaving the original image untouched, and returning the result as a new image.
Here is an example that uses the :class:`Randomize` algorithm. This algorithm feels the pixels of the image with random
values between 0.0 and 1.0
.. code-block:: python
# creates an algorithm object
rand_alg = img.alg.Randomize()
# applies algorithm object in place, overwriting the image
im.ApplyIP( rand_alg )
Now that we have some (noisy) data present, let us run another algorithm, this time a Gaussian filter with a sigma of 4 pixel.
im.ApplyIP( img.alg.GaussianFilter(4.0) ) # apply temporary algorithm object in-place
As you can see, it is not always necessary to create an independent algorithm instance first, in many cases a temporary object will suffice (this applies to the randomization algorithm as well, 'im.ApplyIP(alg.Randomize())' would have been fine). However, when used this way, the algorithm class will cease to exist as soon as the algorithm is applied. This can be important if the algorithm stores some values that need to be recovered later. For example:
stat=img.alg.Stat()
im.ApplyIP(stat)
mean=stat.GetMean()
Algorithms are stateful objects and can store values. The 'Stat' algorithm computes basic statistics about the image it is applied on (maximum and minimum values, standard deviations, etc). The data are stored within the algorithm instance and can be recovered using the algorithm's methods. It would obviously make very little sense not to create an instance of the 'Stat' algorithm. When the algorithms ceases to exist, all information would be lost.
Applying a Fourier Transform
An image is Fourier-transformed using the 'img.alg.FFT()' algorithm object:
im=io.LoadImage("imagename.tif") # load the image
# create an instance of the fft algorithm object
fft=img.alg.FFT()
# do the actual Fourier transformation
im_ft=im.Apply(fft)
# back-transform
im2 = im_ft.Apply(fft)
# if this is run from within the dng graphical frontend, open viewers to look at the images
gui.CreateDataViewer(im)
gui.CreateDataViewer(im_ft)
gui.CreateDataViewer(im2)
It is not really necessary to use the 'fft' variable to store the 'im.alg.FFT()' instance, a temporary object can be used, since the 'FFT' algorithm object is stateless. In addition, the algorithm can be applied in-place to avoid the creation of a second image:
im=io.LoadImage("imagename.tif") # load the image
# do the actual Fourier transformation, in-place using temporary object
im.ApplyIP(alg.FFT())
# repeating this command will do the back-transform
im.ApplyIP(alg.FFT())
As said before, the 'alg.FFT()' algorithm does not require a direction to be given, this is implicitly determined by the active domain of the underlying image state: a 'SPATIAL' image will always be transformed to the 'FREQUENCY' domain, and vice-versa.
Usage of Image Algorithms
--------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment