def extract_patches(image, patch_size): """ From image: extract patches, flatten patches """ patches = impatch.patch(image, patch_size=patch_size) patches = [imutil.flatten_image(patch) for patch in patches] patches = np.array(patches) return patches
def test_image_patch_size(self): patches = impatch.patch(self.testImage, patch_size=3) for patch in patches: # X, correct width self.assertEqual(len(patch[0]), 3) # Y, correct height self.assertEqual(len(patch), 3)
def test_image_patch_all(self): patches = impatch.patch(self.testImage, patch_size=2) #16 patches of size 2x2 in test image self.assertEqual(len(patches), 16)
def test_image_patch_amount(self): patches = impatch.patch(self.testImage, n=7, patch_size=2) #Requested 7 patches self.assertEqual(len(patches), 7)