def test_HD(): imp = IJ.openImage(filePath.getAbsolutePath()) stack = imp.getStack() ip1 = stack.getProcessor(1).duplicate() ip2 = stack.getProcessor(2).duplicate() [ip1, s] = scaleLongSide(ip1, longSide) if (Scale == 1): ip2 = scale(ip2, s) maskA = impMask1.duplicate() maskB = impMask2.duplicate() # IJ.run(maskA, "Invert", "") # IJ.run(maskB, "Invert", "") IJ.run(maskA, "Outline", "") IJ.run(maskB, "Outline", "") # IJ.run(maskA, "Invert", "") # IJ.run(maskB, "Invert", "") maskA.show() maskB.show() impMask1.show() MaskArea1 = maskArea( impMask1.getProcessor() ) impMask2.show() MaskArea2 = maskArea( impMask2.getProcessor() ) hd = Hausdorff_Distance() hd.exec( maskA, maskB ) print(hd.getAveragedHausdorffDistance()) print(hd.getHausdorffDistance())
def hdist( ip1, ip2 ): mask1 = ImagePlus('mask1',ip1) mask2 = ImagePlus('mask2',ip2) # make outlines from the masks IJ.run(mask1, "Outline", "") IJ.run(mask2, "Outline", "") hd = Hausdorff_Distance() hd.exec( mask1, mask2 ) return hd.getHausdorffDistance(), hd.getAveragedHausdorffDistance()
def test_HD(): imp = IJ.openImage(filePath.getAbsolutePath()) stack = imp.getStack() ip1 = stack.getProcessor(1).duplicate() ip2 = stack.getProcessor(2).duplicate() [ip1, s] = scaleLongSide(ip1, longSide) if (Scale == 1): ip2 = scale(ip2, s) maskA = impMask1.duplicate() maskB = impMask2.duplicate() # IJ.run(maskA, "Invert", "") # IJ.run(maskB, "Invert", "") IJ.run(maskA, "Outline", "") IJ.run(maskB, "Outline", "") # IJ.run(maskA, "Invert", "") # IJ.run(maskB, "Invert", "") maskA.show() maskB.show() impMask1.show() MaskArea1 = maskArea(impMask1.getProcessor()) impMask2.show() MaskArea2 = maskArea(impMask2.getProcessor()) hd = Hausdorff_Distance() hd.exec(maskA, maskB) print(hd.getAveragedHausdorffDistance()) print(hd.getHausdorffDistance())
def hdist(ip1, ip2): mask1 = ImagePlus('mask1', ip1) mask2 = ImagePlus('mask2', ip2) # make outlines from the masks IJ.run(mask1, "Outline", "") IJ.run(mask2, "Outline", "") hd = Hausdorff_Distance() hd.exec(mask1, mask2) return hd.getHausdorffDistance(), hd.getAveragedHausdorffDistance()