Skip to content
Open
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
48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
This repo was forked from https://github.com/TimManiquet/occlusion

# Occlusion of Images
This repository contains three Python scripts to apply occlusion to a set of images in different ways. The three ways of occluding images are: by adding **blobs** on top of images, by adding a **partial viewing** mask with apertures on top of the images, or by **deleting** parts of the images. Each of these manipulations, occludes objects in the images such that only a _certain proportion_ of them will remain visible.

<p align="center" width="100%">
<img
src="https://github.com/HOPLAB-LBP/occlusion/blob/main/data/manipulations.png"
alt="Manipulations example"
align="center"
title="Manipulations example"
style="display: inline-block; margin: 0 auto; max-width: 300px">
</p>

## Input images
To ensure that the occluded proportion is calculated correctly, make sure the input images contain an transparent mask (alpha channel) where the object is delineated from the background. These images should be 4-channel, grayscale images. Example of such images can be found in the `input images` folder.

Expand All @@ -12,6 +23,14 @@ To ensure that the occluded proportion is calculated correctly, make sure the i
- glob
- os

## Installation

To install this package using pip, first ensure that you have Git installed on your system. Then, create a new virtual environment and activate it. Finally, run the following command:

```pip install git+https://github.com/TimManiquet/occlusion.git@v0.1```

You can also just clone or download the repo (see below)

## Usage
1. Clone or download this repository.
2. Place the images to occlude in the `img_dir` folder.
Expand Down Expand Up @@ -75,17 +94,28 @@ occlude(

```

This example applies different level and types of occlusion to the images in the `input_dir` folder. The resulting occluded images will be saved in the `output_images` folder. An example output object from this command is found below:
This example applies different level and types of occlusion to the images in the `input_dir` folder. The resulting occluded images will be saved in the `output_images` folder.This example script can be found in the `data` folder, along with a jupyter notebook showing different manipulations.

<img
src="https://github.com/TimManiquet/occlusion/blob/main/outputs/blobs/fewlarge/control/fewlarge_blobs_control_banana.png"
alt="Alt text"
title="Few large blob occluders"
style="display: inline-block; margin: 0 auto; max-width: 300px">
## Outputs
Below are example output images from different commands.

```blobs("path/to/cat.png", easy=10, hard=50, many_small=True, col=255)```

## Installation
<p align="center">
<img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/blobs/manysmall/control/manysmall_blobs_control_cat.png" width="200"/> <img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/blobs/manysmall/low/manysmall_blobs_low_cat.png" width="200"/> <img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/blobs/manysmall/high/manysmall_blobs_high_cat.png" width="200"/>
</p>

To install this package using pip, first ensure that you have Git installed on your system. Then, create a new virtual environment and activate it. Finally, run the following command:
```deletion("path/to/building.png", easy=40, hard=70, many_small=True, few_large=True)```

```pip install git+https://github.com/TimManiquet/occlusion.git@v0.1```
<p align="center">
<img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/deletion/fewlarge/low/fewlarge_deletion_low_building.png" width="200"/> <img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/deletion/fewlarge/high/fewlarge_deletion_high_building.png" width="200"/>
</p>
<p align="center">
<img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/deletion/manysmall/low/manysmall_deletion_low_building.png" width="200"/> <img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/deletion/manysmall/high/manysmall_deletion_high_building.png" width="200"/>
</p>

```partial_viewing("path/to/bird.png", easy=20, hard=90, many_small=False, few_large=True, seed=10)```

<p align="center">
<img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/partial_viewing/fewlarge/control/fewlarge_partial_viewing_control_bird.png" width="200"/> <img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/partial_viewing/fewlarge/low/fewlarge_partial_viewing_low_bird.png" width="200"/> <img src="https://github.com/TimManiquet/occlusion/blob/main/outputs/partial_viewing/fewlarge/high/fewlarge_partial_viewing_high_bird.png" width="200"/>
</p>
2 changes: 1 addition & 1 deletion demo.ipynb → data/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"## <a id='toc1_1_'></a>[Occlude images](#toc0_)\n",
"\n",
"This notebook illustrates how to use the functions contained in this repository. "
"This notebook illustrates how to use the functions contained in this repository. To run this notebook, clone the repository and place the notebook in the root folder, or install the repo using git (see Installation on the README file)."
]
},
{
Expand Down
File renamed without changes.
Binary file added data/manipulations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.