2

I want to augment my data set of images by creating new, synthetic images. One of the operations I want to try is zooming in, i.e. take a subsection of the original image (say 80% of the original size), and intelligently increase that subsection so that it still has the exact same dimension in pixels as the original image. In other words, create new image by zooming in on a portion of an existing image, so that the size of the new images is same as the size of the original.

How do I do this in skimage? Or anything else in Python?

Baron Yugovich
  • 3,843
  • 12
  • 48
  • 76
  • What have you tried? Looks pretty straight forward – hkchengrex Aug 13 '18 at 03:26
  • I don't know where to start, if it's straightforward, please do tell. – Baron Yugovich Aug 13 '18 at 03:29
  • You have mentioned most of it in the question already, let's say you have a image of size 512, take a crop of size (512*0.8), then resize back to 512. [Crop](https://stackoverflow.com/questions/33287613/crop-image-in-skimage) [Resize](http://scikit-image.org/docs/dev/auto_examples/transform/plot_rescale.html) – hkchengrex Aug 13 '18 at 03:36

1 Answers1

1

You may use imgaug.augmenters.geometric.Affine with skimage as a backend (see here):

>>> import imgaug.augmenters as iaa
>>> aug = iaa.Affine(scale=(1.0, 2.0))

enter image description here

Value for scaling will be uniformly sampled per image from the interval (1.0, 2.0). That sampled fraction value will be used identically for both x- and y-axis. The size of the image will stay the same.

irudyak
  • 2,271
  • 25
  • 20