def test3DirectConnectedPixelCorner(self): """If three pixels are directly connected at an corner to the central pixel, the latter has 3 neighboured feature pixels, 2 closely neighboured background pixels, and 1 transition from feature to background, while the corner position depends on the orientation of the corner.""" self.binIm[2,:2] = self.F self.binIm[1,0] = self.F for n in xrange(4): proof = [3,2,n+1,1] rotIm = numpy.rot90(self.binIm,n) result = list(IM.checkNeighbours(rotIm))+[IM.checkTransitions(rotIm)] self.assertEqual(result,proof,"The neighbourhood fingerprint should be %s, but is %s for \n%s!"%(proof,result,rotIm))
def assertEqualRot(self, image, proof, cases=1): for n in xrange(cases): rotIm = numpy.rot90(image, n) result = list( IM.checkNeighbours(rotIm)) + [IM.checkTransitions(rotIm)] self.assertEqual( result, proof, "The neighbourhood fingerprint should be %s, but is %s for \n%s!" % (proof, result, image))
def assertEqualRot(self,image,proof,cases=1): for n in xrange(cases): rotIm = numpy.rot90(image,n) result = list(IM.checkNeighbours(rotIm)) + [IM.checkTransitions(rotIm)] self.assertEqual(result,proof,"The neighbourhood fingerprint should be %s, but is %s for \n%s!"%(proof,result,image))