示例#1
0
        "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("Discrete lambda-medial axis (DLMA)",
        "Lambda axe median discret (DLMA)")


def try_DLMA(la):
    dlma = pink.lambdamedialaxis(IMAGE)
    res = pink.seuil(dlma, la, 0, 255)
    return pink.float2byte(res)


manipulate(try_DLMA, 1, 100, IMAGE)

message("Homotopic skeleton constrained by DLMA",
        "Squelette homotopique contraint par le DLMA")


def try_DLMA_topo(la):
    dlma = pink.lambdamedialaxis(IMAGE)
    constr = pink.seuil(dlma, la, 0, 255)
    constr = pink.float2byte(constr)
    res = pink.skeleton(IMAGE, dlma, 8, constr)
    return res


manipulate(try_DLMA_topo, 1, 100, IMAGE)
示例#2
0
文件: mc-tp6-1.py 项目: lulu1315/Pink
from pink import manipulate as manipulate
from pink import cpp as pink
inv=pink.inverse
global debug
debug=1

# segmentation
def segment(image, height):
    # obtain markers
    mark1 = pink.segmentheight(image, 4, height, 0)
    if debug:
        mark1.writeimage("_mark1")

    # watershed
    wshed1 = pink.watershed(image, mark1, 4)
    if debug:
        wshed1.writeimage("_wshed1")
    return inv(wshed1)

global im
im = pink.readimage("../images/uo.pgm")

print "try different parameters (best one is 20)"
def try_segment(h): return segment(im, h)
manipulate(try_segment, 0, 50, im)

seg = segment(im, 20)
seg.writeimage("../images/uo_w.pgm")

# LuM end of file
示例#3
0
文件: mc-tp1.py 项目: lulu1315/Pink
    eros = pink.erosball(filled, 6)
    dilat = pink.dilatball(eros, 6)
    joints = pink.geodilat(dilat, filled, 8, 1)

    # extract the wires
    result = filled - joints

    return result


def try_seuil(s):
    return pink.seuil(circuit, s, 0, 255)


circuit = pink.readimage("../images/circuit.pgm")
seuil = manipulate(try_seuil, 0, 255, circuit)
wires = find_the_wires(circuit, seuil)
if debug: imview([circuit, wires])
#wires.writeimage("wires.pgm")

print("calling surimp for package generation")
pink.surimp(circuit, wires, "wires.ppm")


# exo1_6
# extraction of the "corne" from the image 'meb.pgm'
def extract_corne(image, threshold):
    seuil = pink.seuil(image, threshold, 0, 255)
    opened = pink.openball(seuil, 3)
    geodilat = pink.geodilat(opened, seuil, 8)
    diff = seuil - geodilat
示例#4
0
        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)


def analj(q):
    return analyzejoints(joints, segment(joints, q))


if debug:
    d = manipulate(analj, 0, 100, joints)
else:
    analyzejoints(joints, seg)
示例#5
0
    rs = result.size[0]
    cs = result.size[1]
    for y in range(cs):
        for x in range(rs):
            R = pow((xc-x)*(xc-x) + (yc-y)*(yc-y), 0.5)
            T = (1.0 * result[[x,y]]) - (alpha * R)
            if T > 255:
                T = 255
            if T < 0:
                T = 0
            result[[x,y]] = int(round(T))
    return(result)

img = pink.readimage("../images/mortier_2d.pgm")
xc = 144 # the center is supposed to be known -
yc = 138 # otherwise we have to analyse the 3D image to "guess" it
alpha = find_bias(img, xc, yc) 
res = correct_bias(img, xc, yc, alpha)

def sm(q): return pink.seuil(img,q)
def rm(q): return pink.seuil(res,q)

if debug:
    imview([img, res])
    manipulate(sm, 0, 255)
    manipulate(rm, 0, 255)

imview(res)

# LuM end of file
示例#6
0
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)

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


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


a_int = manipulate(cb, 1, 255)

res = correctbias(image, a_int)


def s2(q):
    return pink.seuil(res, q)
示例#7
0
文件: test.py 项目: lulu1315/Pink
# UjoImro, 2011

import pink

## #from pink import windowing
## #windowing.options.silent=False

I = pink.cpp.readimage("../images/circuit2.pgm")


def circuit(value):
    global I
    return pink.cpp.seuil(I, value)


pink.manipulate(circuit, 0, 255)

# LuM end of file
示例#8
0
        "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")


def try_erosion4(radius):
    return pink.erosball(IMAGE, radius, 4)


manipulate(try_erosion4, 0, 40, IMAGE)

message("  - se = 8-distance ball", "  - es = boule de la 8-distance")


def try_erosion8(radius):
    return pink.erosball(IMAGE, radius, 8)


manipulate(try_erosion8, 0, 40, IMAGE)

message("  - se = Euclidean ball", "  - es = boule euclidienne")


def try_erosion(radius):
    return pink.erosball(IMAGE, radius)