def analyzejoints(image, seg): # extracts thin pores ball = pink.genball(3) # The following line is the definition of closing, so it can be # replaced by a single operator #tophat = pink.erosion(pink.dilation(image, ball), ball) - image tophat = pink.closing(image, ball) - image if debug: tophat.writeimage("_tophat") thinpores = pink.seuil(tophat, 17) if debug: thinpores.writeimage("_thinpores") # extracts thin pores black = inv(pink.seuil(image, 150)) thickpores = pink.segmentarea(black, 4, 100, 0) thickpores = pink.dilation(thickpores, pink.genball(1)) if debug: thickpores.writeimage("_thickpores") # extracts joints joint = seg - thickpores 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)
## try a threshold ### homotopic skeleton by shrinking uo = pink.readimage("../images/uo.pgm") htkern = pink.htkern(uo, 4) #htkern.writeimage("image.pgm") minima = pink.minima(htkern, "4") #minima.writeimage("image.pgm") ### lambda skeletons lam = pink.lambdaskel(uo, 4, 15) minima = pink.minima(lam, "4") lam = pink.lambdaskel(uo, 4, 24) minima = pink.minima(lam, "4") pink.surimp(uo, inv(minima), "surimp.ppm") ### we can also try the gradient with any image # # ### Greyscale filtering # ### angiographie # angio = pink.readimage("../images/angiogra.pgm") # vois8 = pink.char_image([3,3]).fill(255) # vois8.center=[1,1] # rank = pink.rankfilter(angio, vois8, 1, 1, 0.5) # rank.writeimage("image.pgm") # ### lennab # lennab = pink.readimage("../images/lennab.pgm") # vois25 = pink.char_image([5,5]).fill(255)
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 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
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) pink.surimp(joints, analj(d), "joints_seg.ppm") # LuM end of file
seuil = pink.seuil(diff, 94) if debug: view3d(carotide, seuil) component = pink.selectcomp(seuil, 26, 58, 46, 0) if debug: view3d(carotide, component) carotide_seg = component ### the skeleton operator axonepair = pink.readimage("../images/axonepair.pgm") #imview(axonepair) ## HUGUES WRITE ME! blank = pink.char_image(axonepair.size) skeleton = pink.skeleton(axonepair, blank, 8) #imview(skeleton) pink.surimp(axonepair, skeleton, "axoskel.ppm") ### distances dist = pink.distc(axonepair, 4) dist.writeimage("imagea.pgm") ### randrgb will be replaced with imview colourmap (rand rgb) dist = pink.distc(axonepair, 8) dist.writeimage("imageb.pgm") dist = pink.distc(axonepair, 0) dist.writeimage("imagec.pgm") ### skeletons guided by a priority image skeleton = pink.skeleton(axonepair, 4, 8) pink.surimp(axonepair, skeleton, "imagea.ppm")
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 junctions = pink.ptjunction(skeleton, 8) holes = pink.geodilat(junctions, outils, 8) if debug: imview([outils, holes]) pink.surimp(outils, holes, "holes.ppm") # sol_outils4