Example #1
0
    def test__pass_through_user_img(self):
        F = np.eye(2, dtype=np.float)
        image_deformer = vlab.imageDeformer_from_defGrad(F)

        downsampler = vlab.Downsampler(image_shape=self.img_shape,
                                       factor=1,
                                       fill=1.,
                                       pixel_offset_stddev=0.0)

        noise_injector = lambda img: img

        virtualTest = vlab.SyntheticImageGenerator(
            speckle_image=self.image,
            image_deformer=image_deformer,
            downsampler=downsampler,
            noise_injector=noise_injector,
            n=10)

        deviation = np.abs(virtualTest(1) - self.image)

        if np.max(deviation) > self.tol:
            self.fail(
                "Image changed value or orientation. Largest error is%f" %
                np.max(deviation))
Example #2
0
speckle_image = vlab.rosta_speckle(super_image_shape,
                                   dot_size=4,
                                   density=0.5,
                                   smoothness=2.0)

displacement_function = vlab.deformation_fields.harmonic_bilat

# Make an image deformed
image_deformer = vlab.imageDeformer_from_uFunc(displacement_function,
                                               omega=2 * np.pi /
                                               (500. * downsample_factor),
                                               amp=2.0 * downsample_factor)

# Make an image down-sampler including downscaling, fill-factor and sensor grid irregularities
downsampler = vlab.Downsampler(image_shape=super_image_shape,
                               factor=downsample_factor,
                               fill=.95,
                               pixel_offset_stddev=0.05)

# Make a noise injector producing 2% gaussian additive noise
noise_injector = vlab.noise_injector("gaussian", sigma=.02)

# Make an synthetic image generation pipeline
image_generator = vlab.SyntheticImageGenerator(speckle_image=speckle_image,
                                               image_deformer=image_deformer,
                                               downsampler=downsampler,
                                               noise_injector=noise_injector,
                                               n=n_imgs)
# Put it into an image stack
image_stack = dic.ImageStack(image_generator)

# Now, make a mesh. Make sure to use enough elements