Skip to content

Commit

Permalink
Merge pull request #153 from UBC-MDS/docs
Browse files Browse the repository at this point in the history
Docs to develop
  • Loading branch information
yfan810 authored Feb 3, 2025
2 parents 1e51708 + e720a80 commit 54c930e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
## Features

* Flipping: `flip(image, direction=0)`
Flips the input image either horizontally or vertically. Useful for augmenting datasets by introducing mirror-image variations. `0` = horizontal flip, `1` = vertical flip
flips the input image either horizontally or vertically. Useful for augmenting datasets by introducing mirror-image variations. `0` = horizontal flip, `1` = vertical flip

* Scaling: `scale(image, N)`
Resizes the input image by a given scale factor `N`. This is crucial for normalizing or creating variations in image resolution.
resizes the input image by a given scale factor `N`. This is crucial for normalizing or creating variations in image resolution.

* Blurring: `blur(image, stdev=1.0)`
Applies a Gaussian blur effect to the image. Helps simulate real-world noise or reduce sharpness for specific use cases.
applies a Gaussian blur effect to the image. Helps simulate real-world noise or reduce sharpness for specific use cases.

* Grayscaling: `grayscale(image)`
Converts the image to grayscale. Ideal for models that only require intensity information, excluding color features.
converts the image to grayscale. Ideal for models that only require intensity information, excluding color features.

* Augmenting with a sequence of operations: `augment(images, operations)`
Applies a sequence of user-defined augmentation operations to a list of images. Useful for image generating images for computer vision tasks.
applies a sequence of user-defined augmentation operations to a list of images. Useful for image generating images for computer vision tasks.

## Installation
To install from pypi:
Expand Down Expand Up @@ -55,34 +55,34 @@ $ pytest
```

## Usage
A few exampls to get you sarted with `imagenie`:
A few exampls to get you started with `imagenie`:

1. Import the functions from the package

```
from imagenie.flip import flip
from imagenie.scale import scale
from imagenie.blur import blur
from imagenie.grayscale import grayscale
from imagenie.augment import augment
```
```
from imagenie.flip import flip
from imagenie.scale import scale
from imagenie.blur import blur
from imagenie.grayscale import grayscale
from imagenie.augment import augment
```
2. Load the images as Numpy arrays
```
import matplotlib.pyplot as plt
image = plt.imread(IMAGE_PATH)
image2 = plt.imread(IMAGE_PATH)
```
```
import matplotlib.pyplot as plt
image = plt.imread(IMAGE_PATH)
image2 = plt.imread(IMAGE_PATH)
```
3. Leverage `imagenie`'s image modifictaion functions
3. Leverage `imagenie`'s image modification functions
- Flip image horizontaly or vertically
- Flip image horizontally or vertically
```
flipped_image = flip(image, direction = 1)
```
- Scale image by a desrired scaling factore
- Scale image by a desired scaling factor
```
scaled_image = scale(image, N = 0.4)
```
Expand All @@ -92,7 +92,7 @@ image2 = plt.imread(IMAGE_PATH)
blurred_image = blur(image, stdev = 2.0)
```
- Convert RGB to graycsaled images
- Convert RGB to grayscaled images
```
grayed_image = grayscale(image)
```
Expand Down
31 changes: 15 additions & 16 deletions docs/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"id": "604f4f39-2a16-4f40-aee6-27357525be58",
"metadata": {},
"source": [
"ImaGenie helps with image augmentation and modification, providing a variety of functions to manipulate images for machine learning, computer vision, or creative purposes. Whether you need to flip, scale, convert to grayscale, or blur images, ImaGenie is your one-stop solution for fast and efficient image manipulation.\n",
"`imagenie` helps with image augmentation and modification, providing a variety of functions to manipulate images for machine learning, computer vision, or creative purposes. Whether you need to flip, scale, convert to grayscale, or blur images, `imagenie` is your one-stop solution for fast and efficient image manipulation.\n",
"\n",
"ImaGenie offers the following functionalities: flip, grayscale, scale, and blur. It also allows you to augment multiple images with a series of these operations.\n",
"`imagenie` offers the following functionalities: flip, grayscale, scale, and blur. It also allows you to augment multiple images with a series of these operations.\n",
"\n",
"Let’s familiarize you with this package through a series of pictures of Sir Capybara Genie’s life journey."
]
Expand Down Expand Up @@ -43,7 +43,7 @@
"id": "4ed98a65-3640-4b20-ad39-1e3e9acdeaa0",
"metadata": {},
"source": [
"ImaGenie is designed to work with data in the form of numpy arrays. Let's import Sir Capybara's images using matplotlib and convert them into numpy arrays accordingly. "
"`imagenie` is designed to work with data in the form of numpy arrays. Let's import Sir Capybara's images using matplotlib and convert them into numpy arrays accordingly. "
]
},
{
Expand Down Expand Up @@ -128,16 +128,15 @@
"id": "994d88fe-ba50-40bf-8ae6-5a3b76116d42",
"metadata": {},
"source": [
"## Grayscale an image\n",
"### Transforming a Color Image into a Timeless Grayscale Version"
"## Grayscale an image"
]
},
{
"cell_type": "markdown",
"id": "814543c2-2bc8-420f-934d-b7cd35b7ca25",
"metadata": {},
"source": [
"The function `grayscale()` in the `ImaGeneie` package converts the image to grayscale, i.e., it removes all color and reduces it to varying shades of gray. \n",
"The function `grayscale()` in the `imagenie` package converts the image to grayscale, i.e., it removes all color and reduces it to varying shades of gray. \n",
"\n",
"This is ideal for machine learning models that focus on intensity information, simplifying computations and highlighting structural features of the image, particularly when color information is not important."
]
Expand Down Expand Up @@ -181,15 +180,15 @@
"id": "85b4c65d",
"metadata": {},
"source": [
"## Blur an Image"
"## Blur an image"
]
},
{
"cell_type": "markdown",
"id": "8c6247b7",
"metadata": {},
"source": [
"The function `blur` in the `ImaGenie` package adds a Gaussian Blur by adding noise to a 3-channel input image. It leverages the Gaussian distribution with a provided value of standard deviation, `stdev` which defaults at 1.0.\n",
"The function `blur` in the `imagenie` package adds a Gaussian Blur by adding noise to a 3-channel input image. It leverages the Gaussian distribution with a provided value of standard deviation, `stdev` which defaults at 1.0.\n",
"\n",
"In image augmentation, blurring is useful for simulating real-world imperfections, such as motion blur or out-of-focus elements, enhancing a model's ability to handle noisy or degraded inputs in practical scenarios."
]
Expand Down Expand Up @@ -232,15 +231,15 @@
"id": "9aa3191b-cc37-4593-b2ed-f72272e1c20e",
"metadata": {},
"source": [
"## Flip an Image"
"## Flip an image"
]
},
{
"cell_type": "markdown",
"id": "3cb47589-4713-46ac-93c5-bd3d57fbb2e9",
"metadata": {},
"source": [
"the `flip()` function in the `ImaGenie` packa flips the input image either horizontally or vertically. The `direction` `0` implies horizontal flipping and `1` implies vertical flipping. \n",
"the `flip()` function in the `imagenie` packa flips the input image either horizontally or vertically. The `direction` `0` implies horizontal flipping and `1` implies vertical flipping. \n",
"\n",
"This technique is crucial in image augmentation for introducing mirrored variations, thereby increasing dataset diversity and reducing overfitting in machine learning models."
]
Expand All @@ -250,7 +249,7 @@
"id": "d2d49a1d-6294-4589-bf64-7e55202057c7",
"metadata": {},
"source": [
"### But then he studied data scinece and his life flipped upside down!"
"### But then he studied data science and his life flipped around!"
]
},
{
Expand Down Expand Up @@ -284,7 +283,7 @@
"id": "84dfc883-ab0b-483c-a310-40c4b9b23b9e",
"metadata": {},
"source": [
"#### He alslo flipped horizontally"
"#### He also flipped horizontally"
]
},
{
Expand Down Expand Up @@ -319,15 +318,15 @@
"id": "4075afd8-aa2f-47a1-b12d-d19c607e949a",
"metadata": {},
"source": [
"## Scale an Image"
"## Scale an image"
]
},
{
"cell_type": "markdown",
"id": "495d3f0c-8de3-4688-86fb-7f0e111fb0e4",
"metadata": {},
"source": [
"The `scale()` function in the `ImaGenie` package resizes an image using a scaling factor, `N`. The scaling factor `N` is a positive float number, and defaults to 1.\n",
"The `scale()` function in the `imagenie` package resizes an image using a scaling factor, `N`. The scaling factor `N` is a positive float number, and defaults to 1.\n",
"\n",
"Scaling is a fundamental augmentation technique, allowing for variations in image size and resolution. It’s especially important for training models to recognize objects at different scales, improving performance across varying perspectives or distances."
]
Expand Down Expand Up @@ -409,15 +408,15 @@
"id": "a0798902-d0de-4b2b-8502-68f5b5f1282d",
"metadata": {},
"source": [
"## Augment One or More Images"
"## Augment images "
]
},
{
"cell_type": "markdown",
"id": "d75b71cf-cd5d-4c2c-b7c8-c973268d3cb4",
"metadata": {},
"source": [
"The `augment()` function in the `ImaGenie` package applies a sequence of user-defined augmentation operations to a batch of images. It only allows previously mentioned operations. \n",
"The `augment()` function in the `imagenie` package applies a sequence of user-defined augmentation operations to a batch of images. It only allows previously mentioned operations. \n",
"\n",
"This is a powerful tool for creating robust training datasets by generating diverse versions of input images. Augmentation improves a model's ability to generalize, making it resilient to variations in lighting, orientation, or scale during deployment."
]
Expand Down

0 comments on commit 54c930e

Please sign in to comment.