Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/setanarut/decompose
Decompose image into layers (Fast Soft Color Segmentation)
https://github.com/setanarut/decompose
alpha-compositing color-separation decomposition image-processing pytorch-implementation segmentation
Last synced: 26 days ago
JSON representation
Decompose image into layers (Fast Soft Color Segmentation)
- Host: GitHub
- URL: https://github.com/setanarut/decompose
- Owner: setanarut
- License: mit
- Created: 2023-11-01T18:55:21.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-31T22:59:17.000Z (11 months ago)
- Last Synced: 2024-10-22T22:19:45.870Z (2 months ago)
- Topics: alpha-compositing, color-separation, decomposition, image-processing, pytorch-implementation, segmentation
- Language: Python
- Homepage:
- Size: 1.97 MB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Decompose
[Fast Soft Color Segmentation](https://github.com/pfnet-research/FSCS) without `Residue predictor`.
[Paper PDF](https://arxiv.org/pdf/2004.08096.pdf)## Installation
```bash
pip install git+https://github.com/setanarut/decompose
```## Example
```python
from decompose.decomposer import decompose
from PIL import Imageimg = Image.open("image.jpg")
layers = decompose(img)for layer in layers:
print(layer)# Decomposer mask generation...
# Decomposer processing alpha layers...
# Decomposer Done!
#
#
#
#
#
#
#
```You can write layers as [ORA](https://docs.krita.org/en/general_concepts/file_formats/file_ora.html) file
```python
from decompose.utils import images_to_ORAimages_to_ORA(layers).save("img.ora")
```If palette is not given as an argument, a palette is created automatically. Colors can be selected manually.
```python
manual_palette = [
(255, 255, 255),
(3, 135, 3),
(3, 193, 160),
(1, 167, 255),
(255, 243, 0),
(193, 0, 0),
(3, 0, 2),
]
layers = decompose(img, manual_palette)
```## decomp command-line tool example
Saves layers as ORA (Open Raster) file. It can be opened with Krita. Also saves the palette.
```bash
$ decomp ~/Desktop/img.png# Decomposer mask generation...
# Decomposer processing alpha layers...
# Decomposer Done!
# ORA saved: img.ora
# 7
# Palette saved: img_palette.png
```## Note
The model only supports 7 colors. The same color can be repeated for less color.
![palette](./assets/palette.jpg)