コード例 #1
0
ファイル: renderPicker.py プロジェクト: lulu1315/Pink
def render( image1=0, image2=0 ):

    ## to be removed later
    if (image1==0):
        image1 = readimage("/Users/talbot/research/Olivia/images/seg_art_008.pgm")
    
    mesh1 = mcube(image1, 0, 0, 0)
    if image2!=0:
        mesh2 = mcube(image2, 0, 0, 0)
    else:
        mesh2 = 0

    top = tk.Toplevel(pink.windowing.root)

    render_obj=render_class(mesh1, mesh2)
    application = app(render_obj, pink.windowing.root)
    top.withdraw()


    application.mainloop()
    application.top.withdraw()
コード例 #2
0
# Michel Couprie, 2011
# CeCILL free-software license

# illustration of filtered Euclidean skeletons

from pink import imview
from pink import manipulate as manipulate
from pink import cpp as pink

global IMAGE
IMAGE = pink.readimage("../images/fish1.pgm")

global LANG
LANG = "en"


def message(mes_en, mes_fr):
    if LANG == "fr":
        print mes_fr
    else:
        print mes_en


message("\n\nDemonstration of skeletonization operators",
        "\n\nDemonstration des operateurs de squelettisation")
message("Check the 'Superimpose' button in the window",
        "Activer l'option 'Superimpose' dans l'interface")
message("Click 'Exit' to close the window and continue",
        "Cliquer sur 'Exit' pour passer au suivant")
print("              ----------------")
コード例 #3
0
# ### hint: delete the points for which tb==1
# shrunk = fill_the_hole(tores, 0, 10)
# if debug:
#     render(shrunk, tores)

# ### the distance is necessary
# chaise = pink.readimage("../images/chaise.pgm")
# shrunk = fill_the_hole(chaise)
# blank = pink.char_image(chaise.size)
# bad_shrunk = pink.toposhrink( inv(pink.frame(blank,255)), pink.int_image(chaise.size), 26, 0, 10, 1, 1, chaise )

# if debug:
#     render(shrunk, chaise)

### application vertebrae
vertebre = pink.frame(pink.readimage("../images/vertebre.pgm"), 0)
#shrunk = fill_the_hole(vertebre, 0, 10)
#if debug:
#    render(shrunk, vertebre)

# #### REVISION REQUIRED

# ### introduction of the size parameter
# closed1 = pink.holeclosing(vertebre, 26, 0)
# closed2 = pink.holeclosing(vertebre, 26, 10000)
closed3 = pink.holeclosing(vertebre, 26, 6)
#if debug:
render(closed3, vertebre)

# #### end of REVISION REQUIRED
コード例 #4
0
def seg_gray(image, thr1, thr2):
    t1 = pink.seuil(image, thr1)
    t2 = pink.seuil(image, thr2)
    res = pink.asf(t1 - t2, 2)
    return (res)


# combine three binary images into one label image
def combine(im1, im2, im3):
    i1 = pink.normalize(im1, 0, 1)
    i2 = pink.normalize(im2, 0, 2)
    i3 = pink.normalize(im3, 0, 3)
    return (i1 + i2 + i3)


img = pink.readimage("../images/mortier_3d.pgm")

show_histo(img)

imgf = filtering(img, 2)

white = seg_white(imgf, 197, 80, 80)
if debug:
    view3d(img, white)
    white.writeamira("_white")

black = seg_black(imgf, 128)
if debug:
    view3d(img, black)
    black.writeamira("_black")
コード例 #5
0
ファイル: ht-tp2.py プロジェクト: lulu1315/Pink
# UjoImro, 2010
# CeCILL free-software license

# Hugues' TP-2 / Segmentation1

from pink import cpp as pink

# ex 4.1
numbers = pink.readimage("../images/numbers.pgm")
ball = pink.genball(5)
openn = pink.opening(numbers, ball)
normalized = pink.seuil(numbers - openn, 10, 0, 255)
normalized.writeimage("normalized.pgm")

# ex 5.1-1
cell = pink.readimage("../images/cell.pgm")
ball = pink.genball(1)
dcell = pink.dilation(cell, ball)
ecell = pink.erosion(cell, ball)
pink.normalize(dcell - ecell).writeimage("grad.pgm")

# ex 5.1-2
## HELP ME!!!

#ex 6.1-1
bloodcells = pink.readimage("../images/bloodcells.pgm")
marker = pink.char_image(bloodcells.size)
marker[[50, 50]] = 255
marker.writeimage("marker.pgm")
ws = pink.watershed(bloodcells, marker, 8)
コード例 #6
0
ファイル: mc-tp1.py プロジェクト: lulu1315/Pink
from pink import cpp as pink

debug = True


# exo1_1
# filter the image from noise
def filter(image, radius_opening, radius_closing):
    eroded = pink.erosball(image, radius_opening)
    recons1 = pink.geodilat(eroded, image, 8)
    dilated = pink.dilatball(recons1, radius_closing)
    result = pink.geoeros(dilated, recons1, 8)
    return result


cell = pink.readimage("../images/cell.pgm")
filtered = filter(cell, 2, 2)

print("imview listview test")
imview([cell, filtered])

if debug: imview(filtered)

#filtered.writeimage("cell_filtered.pgm")


# exo1_2
# eliminate the objects touching the border
def remove_objects(image):
    frame = pink.frame(pink.char_image(image.size), 255)
    border_objects = pink.geodilat(frame, image, 8)
コード例 #7
0
ファイル: mc-tp5-4.py プロジェクト: lulu1315/Pink
def carbide_detection(image, rad_bth, seuil, rad_op):
    es = disk_structuring_element(rad_bth)
    if DEBUG:
        imview(es)
        raw_input("press enter to continue...")
        es.writeimage("_es")
    bth = black_top_hat(image, es)
    if DEBUG:
        imview(bth)
        raw_input("press enter to continue...")
        bth.writeimage("_bth")
    thr = pink.seuil(bth, seuil)
    if DEBUG:
        imview(thr)
        raw_input("press enter to continue...")
        thr.writeimage("_thr")
    opb = pink.openball(thr, rad_op)
    if DEBUG:
        imview(opb)
        raw_input("press enter to continue...")
        opb.writeimage("_opb")
    res = pink.attribute(opb, 8, 0, 0, 0)
    return res


img = pink.readimage("../images/carbures.pgm")
res = carbide_detection(img, 9, 40, 2)
imview(res)

# LuM end of file
コード例 #8
0
ファイル: mc-demo-morph1.py プロジェクト: lulu1315/Pink
from pink import manipulate as manipulate
from pink import cpp as pink

global LANG
LANG = "en"


def message(mes_en, mes_fr):
    if LANG == "fr":
        print mes_fr
    else:
        print mes_en


global IMAGE
IMAGE = pink.readimage("../images/blobs.pgm")

message("\n\nDemonstration of basic morphological operators",
        "\n\nDemonstration des operateurs morphologiques de base")
message("Check the 'Superimpose' button in the window",
        "Activer l'option 'Superimpose' dans l'interface")
message("Click 'Exit' to close the window and continue",
        "Cliquer sur 'Exit' pour passer au suivant")
print("              ----------------")

message("Demonstration of erosions", "demonstration de l'erosion")

message("  - structuring element (se) = 4-distance ball",
        "  - es = boule de la 4-distance")

コード例 #9
0
    if debug:
        joint.writeimage("_joint")
    jointlen = pink.area(joint)
    print("longueur totale des joints : " + str(jointlen))
    # extracts coroded parts of joints
    corojoint = pink.min(pink.dilation(thinpores, pink.genball(1)), joint)
    if debug:
        corojoint.writeimage("_corojoint")
        pink.surimp(joint, corojoint, "_res")
    corojointlen = pink.area(corojoint)
    print("longueur des joints corrodes : " + str(corojointlen))

    return (corojoint)


joints = pink.readimage("../images/joints.pgm")


def segj(q):
    return segment(joints, q)


if debug:
    height = manipulate(segj, 0, 15, joints)
else:
    height = 7

seg = segment(joints, height)
imview(seg)

コード例 #10
0
# Michel's TP-3 for 3D images

from pink import view3d, render, seuilmesh
from pink import cpp as pink
import pink.windowing as wd

inv = pink.inverse

# ## uncomment to ask before quitting dialogs
# wd.options.silent=False

debug = True
# ## uncomment to perform the debug operations
# debug=True

lettre_a = pink.readimage("../images/lettre_a.pgm")
carotide = pink.readimage("../images/carotide.pgm")

if debug:
    view3d(lettre_a)
if debug:
    view3d(carotide)
#seuilmesh(carotide)

seuil = pink.seuil(carotide, 105)
dilated = pink.dilatball(seuil, 2)
if debug:
    view3d(carotide, dilated)
diff = carotide - dilated

seuil = pink.seuil(diff, 94)
コード例 #11
0
ファイル: mc-tp2.py プロジェクト: lulu1315/Pink
# UjoImro, 2010
# CeCILL free-software license

# Michel's TP-2

from pink import imview
from pink import cpp as pink

debug = True

#sol_outils1
# extraction of thick simple objects

outils = pink.readimage("../images/outils.pgm")
skeleton = pink.skeleton(outils, 0, 8)
#pink.surimp(outils, skeleton, "skeletonized.ppm")
isolated_points = pink.ptisolated(skeleton, 8)
#pink.surimp(skeleton, isolated_points, "ptisolated.ppm")
simple_objects = pink.geodilat(isolated_points, outils, 8)
#pink.surimp(outils, dilated, "dilated.ppm")
eroded = pink.erosball(simple_objects, 10)
thick = pink.geodilat(eroded, outils, 8)
pink.surimp(outils, thick, "thick.ppm")

# sol_outils2
# extraction of thin simple objects
thin = simple_objects - thick
pink.surimp(outils, thin, "thin.ppm")

# sol_outils3
# extraction of object with more than one holes
コード例 #12
0

# bias correction
def correctbias(img, alpha):
    smooth = pink.gaussianfilter(img, alpha / 200.)
    mm = pink.minmax(smooth)
    s = smooth - mm[0]
    res1 = img - s
    minmax = pink.minmax(img)
    res = pink.normalize(res1, minmax[0], minmax[1])
    return pink.float2byte(res)


global image
#image = pink.readimage("../images/uo.pgm")
image = pink.convert2float(pink.readimage("images/pex1.pgm"))


# try gaussian filtering (acts on global 'image' - for use by 'manipulate')
def gaussian(alpha_int):
    alpha = alpha_int / 200.0
    res = pink.gaussianfilter(image, alpha)
    return res


def ss(q):
    return pink.seuil(image, q)


if debug:
    manipulate(ss, 0, 255)
コード例 #13
0
ファイル: mc-tp7-0.py プロジェクト: lulu1315/Pink
# Michel Couprie, 2011
# CeCILL free-software license

# crop image (test)

from pink import cpp as pink
from pink import imview as imview


def crop(image, x, y, w, h):
    res = pink.char_image([w, h])
    res = pink.insert_image(res, image, [-x, -y])
    return res


rs = 100  # row size for a tile
cs = 100  # column size for a tile

big = pink.readimage("wholeimage.pgm")
t0 = crop(big, 0, 0, rs, cs)
t1 = crop(big, rs, 0, rs, cs)
t2 = crop(big, 0, cs, rs, cs)
t3 = crop(big, rs, cs, rs, cs)

imview([big, t0, t1, t2, t3])
コード例 #14
0
ファイル: ht-tp1.py プロジェクト: lulu1315/Pink
# UjoImro,HT, 2010-212
# CeCILL free-software license

# Hugues' TP-1

from pink import Imview
from pink import cpp as pink

#ex 3.1-1
#help(pink.geoeros)

#ex 3.1-2
I = pink.readimage("../images/cells.pgm")

viewer1 = Imview(I)

eroded = pink.erosball(I, 1, 0)
viewer1.show(eroded, "eroded")  # spacebar to switch from one image to the next

#ex 3.1-3
recons1 = pink.geodilat(eroded, I, 8, 10)
viewer1.show(recons1, "recons1")
#recons1.writeimage("recons1.pgm")

#ex 3.1-4
# we start from the already partially denoised result
dilated = pink.dilatball(recons1, 1, 0)
recons2 = pink.geoeros(dilated, recons1, 8, 10)

# we save this result
#recons2.writeimage("recons2.pgm")
コード例 #15
0
ファイル: mc-tp7-2.py プロジェクト: lulu1315/Pink
    res = pink.insert_image(res, image, [-x, -y])
    return (res)


RS = 4  # numbers of tiles in a row
CS = 4  # numbers of tiles in a column
rs = 100  # row size for a tile
cs = 100  # column size for a tile

nb_grains = 0
grain_size = 0

for J in range(CS):
    for I in range(RS):
        filename = 'tile%02d.pgm' % (J * CS + I)
        tile = pink.readimage(filename)
        # separate objects into interior and border objects
        frame = pink.frame(pink.char_image(tile.size), 255)
        border_objects = pink.geodilat(frame, tile, 8)
        interior_objects = tile - border_objects
        # measure interior objects
        grain_size = grain_size + pink.area(interior_objects)
        lab = pink.labelfgd(interior_objects, 8)
        nb_grains = nb_grains + pink.minmax(lab)[1]
        if DEBUG:
            print("I,J,s,n: " + str(I) + " " + str(J) + " " + str(grain_size) +
                  " " + str(nb_grains))
        # deal with border objects
        if (I < RS - 1) and (J < CS - 1):
            filename_r = 'tile%02d.pgm' % (J * CS + I + 1)
            tile_r = pink.readimage(filename_r)
コード例 #16
0
# UjoImro, 2012
# ProCarPlan s.r.o.
# CeCILL free-software license

# convert image to graph structure

from pink import imview as imview
from pink import cpp as pink

global DEBUG
DEBUG = 1

im = pink.readimage("../images/uo_w.pgm")
imf = pink.frame(im, 255)  # adds a white frame inside the image
imf = pink.frame_around(imf, 0)  # adds a black frame outside the image
skelim = pink.skeleton(imf, 0, 8)  # get rid of simple points
imview(skelim)

skel = pink.image2skel(skelim, 8)
skel.writeskel("_skelpy.skel")

graph = pink.skel2graph(skel, 1)
graph.writegraph("_graphpy.graph")
graph.writeps("_graphpy.ps", 0.3)

# LuM end of file
コード例 #17
0
global DEBUG
DEBUG=1

# bias correction
def correctbias(img, alpha):
    smooth = pink.gaussianfilter(img, alpha/200.)
    mm = pink.minmax(smooth)
    s = smooth - mm[0]
    res1 = img - s
    minmax = pink.minmax(img)
    res = pink.normalize(res1, minmax[0], minmax[1])
    return res

global image
#image = pink.readimage("../images/uo.pgm")
image = pink.readimage("../images/pex2.pgm")

# try gaussian filtering (acts on global 'image' - for use by 'manipulate')
def gaussian(alpha_int):
    alpha = alpha_int / 200.0
    res = pink.gaussianfilter(image, alpha)
    return res

def ss(q): return pink.seuil(image, q)

if debug: 
    manipulate(ss, 0, 255)

#a_int = manipulate(gaussian, 1, 200) # let the user choose parameter value

def cb(q): return correctbias(image, q)