Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AutoTransformPy/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def mirror (image_path, direction = 'all'):
if not isinstance(direction, str):
raise TypeError("The direction must be a string: 'horizontal', 'vertical', or 'all'")

if not direction in ["horizontal","vertical", "all"]:
if not direction.lower() in ["horizontal","vertical", "all"]:
raise ValueError("The direction must be 'horizontal', 'vertical' or 'all'")

if not os.path.isfile(image_path):
Expand All @@ -50,12 +50,12 @@ def mirror (image_path, direction = 'all'):
mirrored_images = [img]

# flip horizontally
if direction == 'horizontal' or direction == 'all':
if direction.lower() == 'horizontal' or direction.lower() == 'all':
horiz_image = np.fliplr(img)
mirrored_images.append(horiz_image)

# flip vertically
if direction == 'vertical' or direction == 'all':
if direction.lower() == 'vertical' or direction.lower() == 'all':
vert_image = img[::-1]
mirrored_images.append(vert_image)

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AutoTransform

### Contributors
## Contributors

| Name | GitHub |
|---|---|
Expand All @@ -9,11 +9,11 @@
| Rayce Rossum | [RayceRossum](https://github.com/RayceRossum) |


### Overview
## Overview

A common application of supervised machine learning is identifying the object of an image. One issue that users encounter is a model misclassifying a new image because the object is rotated or translated in some way that was not captured in the training images. The purpose of this package is to create a more robust set of images for users to train their model with. The package will accept an image as an input, apply a series of transformations to it, and return an array of transformed pixel values. Transformations include: rotating, mirroring, and translating (shifting the object's location in the frame).

### Functions
## Functions

#### Rotate

Expand All @@ -28,21 +28,21 @@ Mirrors an image in the horizontal and/or vertical direction and returns the pix
Translate will move an image within its frame, so that the topic of the image will be shifted to a new location in the frame. The distance and direction of translation will be chosen randomly, but the user specifies the maximum distance of the translation and the number of images they want generated. It returns the pixel values of the translated images.


### Python Environment
## Python Environment

Scikit-image is a image processing package that contains functions for performing various operations to images, such as rotating or resizing, among many others. AutoTransformPy utilizes some of this packages functionality and builds it out, so the user can easily gain many variations of an image. The intended usage of this package is for the development of a larger set of training images for the training of an image classification algorithms.


### Installation
## Installation

To install AutoTransformPy:

1. In your console, type: `pip install git+https://github.com/UBC-MDS/AutoTransformPy.git`
2. You can now use AutoTransformPy. See usage instructions below:

### Usage
## Usage

#### Rotate
### Rotate

`from AutoTransformPy.rotate import rotate`

Expand All @@ -56,14 +56,14 @@ To install AutoTransformPy:

**Output:**

- An np.array of pixel values of the rotated images. Array contains `num_images`.
- An np.array of pixel values of the rotated images. Array contains `num_images` + 1 images (original plus all translated images)

**Example:**

- `rotate("../tests/imgs/milad.jpg", 10, 280)`


#### Mirror
### Mirror

`from AutoTransformPy.mirror import mirror`

Expand All @@ -83,7 +83,7 @@ To install AutoTransformPy:
- `mirror("../tests/imgs/milad.jpg", "horizontal")`


#### Translate
### Translate

`from AutoTransformPy.translate import translate`

Expand All @@ -104,7 +104,7 @@ To install AutoTransformPy:
- `translate("../tests/imgs/milad.jpg", 5, 80)`


### Package Dependencies
## Package Dependencies

- `numpy`
- `skimage`
Expand Down