registration of microscope images

3 views
Skip to first unread message

gabriel

unread,
Sep 30, 2008, 12:12:46 PM9/30/08
to Priithon
Hi,

I am new to Priithon, and am wondering if anybody can advise me as to
whether or not it is suitable software for my purposes. In order to
avoid diving fully into Priithon only to find out later that this is
not possible / a suitable way, I thought I'd ask you first.

I have series of pictures of microscope sections that I want to align
(register) to be able to make a 3D reconstruction. I have good
knowledge of Python / Numpy / Scipy. It is surprisingly hard to find
open software that does registration and works on my computer at the
same time. It doesn't have to be automatic, as long as it allows me to
efficiently go over the sections and rotate/translate them.

All the best, Gabriel

Sebastian Haase

unread,
Sep 30, 2008, 4:47:15 PM9/30/08
to prii...@googlegroups.com
Hi Gabriel,
I could send you a simple script that I use for this; it is
implementing a simplex optimization and uses cross 2d-image
cross-correlation to calculate a cost-function.
What OS are you using ? Which Python version ?

-Sebastian

Gabriel J.L. Beckers

unread,
Oct 1, 2008, 1:51:18 AM10/1/08
to prii...@googlegroups.com
Many thanks, Sebastian! I am using Linux (Ubuntu 8.04) on a 32-bit Intel
system, and Python 2.5.2 (but could use a different version if needed).

Gabriel
--
Dr. Gabriël J.L. Beckers

Max Planck Institute for Ornithology
Group Neurobiology of Behaviour
Postfach 1564, 82305 Starnberg, Germany

Web: http://www.gbeckers.nl
Phone: +49-8157932273, Fax: +49-8157932285


Sebastian Haase

unread,
Oct 2, 2008, 9:05:39 AM10/2/08
to prii...@googlegroups.com
Hi Gabriel,

what kind of images are you trying to align ?
I was just about to send you my module, when I found that it could not
handle a simple test image that I tried -- something like this:
>>> import simplex
>>> a = F.gaussianArr(shape=(256, 256), sigma=30, peakVal=1, orig=(100,100))
>>> b = F.ringArr(shape=(256, 256), radius1=20, radius2=40, orig=(50,80))
>>> stack = [a,b]
>>> simplex.doAlign(stack, z0=0, z1=1, doAnIso=True, mexSize=0)

"simplex.py" is the module that we have been using for quite some time
.... but it seems to be "broken" right now ..... I'm very puzzled :-(

Anyway, you could also try to do the follow using scipy:

>>> from scipy import optimize
>>> x0 = 10,10,0,1,0,1
>>> zzr = N.array((a,b,b))
>>> def func(x):
tx, ty, rot, mag, gmag2_axis, gmag2 = x
U.trans2d(zzr[1], zzr[2], (tx, ty, rot, mag, gmag2_axis, gmag2))
return 1.-U.S.correlate(zzr[0], zzr[2])

>>> optimize.fmin(func, x0, args=(), xtol=0.0001, ftol=0.0001, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None)
Optimization terminated successfully.
Current function value: 0.016701
Iterations: 424
Function evaluations: 714
[ -5.903 -57.7474 0.0122 0.9248 -0.0087 1.1582]

zzr is here an array of shape 3,256,256: the idea is to align zzr[1]
to zzr[0] and putting the aligned version (tranform of zzr[1]) into
zzr[2]
This can then nicely be viewed using Y.view2(zzr)

If you don't want an anisotropic transformation (i.e. no shearing,
only translation, rotation and magnification), remove the trailing 0,1
of x0 and adjust the first two lines of func.
Note that the angle "rot" is given in degrees.

However even the scipy.optimize.fmin did not work as good as I
expected -- something is still wrong ...
Here is a small screenshot - made with these test images:
>>> a = F.gaussianArr(shape=(256, 256), sigma=30, peakVal=1)
>>> aa=a.copy()
>>> bb=a.copy()
>>> U.trans2d(a,aa, (0, 0, 0, 1, 0, 1.5))
>>> U.trans2d(b,bb, (20, 50, 0, 1, 0, 1.5));U.trans2d(bb.copy(),bb, (0, 0, 25, 1, 0, 1))


-Sebastian

Picture 3.png

Gabriel J.L. Beckers

unread,
Oct 2, 2008, 10:40:05 AM10/2/08
to prii...@googlegroups.com
Hi Sebastian,

Many thanks for the example. I will play around with it.

My images are cryostat-microtome brain sections, photographed (grey
scale) with normal bright light.

Thanks again,
Gabriel


On Thu, 2008-10-02 at 15:05 +0200, Sebastian Haase wrote:
> Hi Gabriel,
>

Reply all
Reply to author
Forward
0 new messages