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 dilated = pink.dilatball(diff, 4) opened2 = pink.openball(dilated, 10) geodilat2 = pink.geodilat(opened2, dilated, 8) closed = pink.closeball(geodilat2, 4) border = pink.border(closed, 8) return border
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
objects = pink.geodilat(holes, cells_filled, 8, -1) cells_final = pink.min(cells_filled, objects) viewer1.show(cells_final, "cells_final") #cells_final.writeimage("cells_final.pgm") #ex 4 ## filtering and inverting circuit = pink.readimage("../images/circuit.pgm") inv = pink.inverse(circuit) inv = pink.seuil(inv, 180, 0, 255) inv = filter_noise(inv) viewer2 = Imview(inv) #inv.writeimage("circ.pgm") # Filtering out the strips to get the round ends round = pink.openball(inv, 5, 0) # plus one round of geodesic dilation to get the shape back roundok = pink.geodilat(round, inv, 8, 1) # note the 1 here viewer2.show(roundok, "roundok") # get the strips by difference strips = inv - roundok viewer2.show(strips, "strips") ## dilation structuring_element = pink.char_image([11, 1]) structuring_element.fill(255) structuring_element.writeimage("se.pgm") structuring_element.center = [5, 0] dilated = pink.dilation(inv, structuring_element) #dilated.writeimage("dil.pgm")
render(test_tp) blank = pink.char_image(cerveau.size) blank[[85, 80, 5]] = 255 blank = pink.inverse(blank) if debug: view3d(cerveau, blank) cerveau_inv = pink.inverse(cerveau) seuil_inv = pink.inverse(seuil) skeleton = pink.skeleton(blank, cerveau_inv, 26, seuil_inv) skeleton = pink.inverse(skeleton) # decimate! if debug: render(skeleton, skeleton) ### Topology controlled opening opened = pink.openball(skeleton, 1) skeleton = pink.skeleton(skeleton, 6, 6, opened) if debug: render(skeleton, skeleton) ### surfasic skeleton prioimage = pink.inverse(pink.distc(skeleton, 0)) skelsurf = pink.skelsurf(skeleton, prioimage, 6) if debug: render(skelsurf, skelsurf) if debug: render(skeleton, skelsurf) ### angiography of the liver foie = pink.readimage("../images/foie.pgm")
def try_opening(radius): return pink.openball(IMAGE, radius)
manipulate(try_opening, 0, 40, IMAGE) message("Demonstration of morphological closing", "demonstration de la fermeture") def try_closing(radius): return pink.closeball(IMAGE, radius) manipulate(try_closing, 0, 100, IMAGE) global IMAGE2 IMAGE2 = pink.openball(IMAGE, 29) message("Demonstration of geodesic dilation", "demonstration de la dilatation geodesique") message(" - se = 4-neighborhood", " - es = 4-voisinage") def try_geodilat4(n): return pink.geodilat(IMAGE2, IMAGE, 4, n) manipulate(try_geodilat4, 0, 250, IMAGE) message(" - se = 8-neighborhood", " - es = 8-voisinage")