Monday, January 17, 2011

Test images for geodesic region growing (watersheed with gray seeds)

Two new 8bits images, made with the gimp, to test watershed with seeds:
cg.jpeg: a grayscale image of a circle
s.jpeg: a grayscale image of two seeds within the circle.








Now let the seeds  grow inside the circle. Using Mahotas from pycrust, here is a python session:

PyCrust 0.9.8 - The Flakiest Python Shell
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import readmagick
import mahotas
c=readmagick.readimg("/home/claire/Applications/ImagesTest/essai01/circle.tif")
print c.shape
(100, 100, 3)
 
s=readmagick.readimg("/home/claire/Applications/ImagesTest/essai01/seeds.tif")
print s.shape
(100, 100)
cg=c[:,:,0]#converts the 3 channels image into a 1 channel grayscale image.
print c.shape
(100, 100, 3)
import pymorph

#converts the 3 channels image into a 1 channel grayscale image.
cg=pymorph.to_gray(c)

print cg.shape
(100, 100)
print s.shape
(100, 100)
lab=mahotas.cwatershed(cg, s)
readmagick.writeimg(lab,"/home/claire/Applications/ImagesTest/essai01/label.tif")
readmagick.writeimg(lab,"/home/claire/Applications/ImagesTest/essai01/label.jpeg")
readmagick.writeimg(cg,"/home/claire/Applications/ImagesTest/essai01/cg.jpeg")
readmagick.writeimg(s,"/home/claire/Applications/ImagesTest/essai01/s.jpeg")
#save the image in jpeg, blogspot doesn't like tif
After watershed the labelled region:


The inner circle region is ok, but outside ...







No comments: