{"id":26928040,"url":"https://github.com/matesxs/elementarise","last_synced_at":"2026-05-05T05:31:22.200Z","repository":{"id":59027929,"uuid":"534617586","full_name":"Matesxs/elementarise","owner":"Matesxs","description":"Library for generating images from basic shapes","archived":false,"fork":false,"pushed_at":"2022-09-11T18:31:25.000Z","size":20012,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T09:43:45.942Z","etag":null,"topics":["art","generative-art","image","image-processing","library","opencv","package","parallel-computing","pil","pillow","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/elementarise/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Matesxs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-09T11:36:57.000Z","updated_at":"2022-09-23T01:24:06.000Z","dependencies_parsed_at":"2022-09-10T23:54:05.046Z","dependency_job_id":null,"html_url":"https://github.com/Matesxs/elementarise","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matesxs%2Felementarise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matesxs%2Felementarise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matesxs%2Felementarise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matesxs%2Felementarise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Matesxs","download_url":"https://codeload.github.com/Matesxs/elementarise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246752571,"owners_count":20827987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["art","generative-art","image","image-processing","library","opencv","package","parallel-computing","pil","pillow","python","python3"],"created_at":"2025-04-02T04:18:21.760Z","updated_at":"2026-05-05T05:31:21.901Z","avatar_url":"https://github.com/Matesxs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elementarise image\n\n## Description\nLibrary for generating images from basic shapes.\n\n### Example\n![o1](https://github.com/Matesxs/elementarise/blob/master/media/cat.jpg?raw=true \"Original\")\n![g1](https://github.com/Matesxs/elementarise/blob/master/media/cat_result.png?raw=true \"Generated\")  \n![o2](https://github.com/Matesxs/elementarise/blob/master/media/eevee.png?raw=true \"Original\")\n![g2](https://github.com/Matesxs/elementarise/blob/master/media/eevee_result.png?raw=true \"Generated\")  \n![o3](https://github.com/Matesxs/elementarise/blob/master/media/portal.png?raw=true \"Original\")\n![g3](https://github.com/Matesxs/elementarise/blob/master/media/portal_result.png?raw=true \"Generated\")\n\n\n## How it works\nThe library is guessing parameters of selected element and placing it on process image with intension of matching the reference image as good as possible.\n\n\n## Setup\n### Instalation\n```\npip install elementarise\n```\n\n### Development\n```\npython setup.py develop\n```\n\n\n## Usage\n### Programatic use\n#### Parameter list\n```python\nElementariser(\n  reference_image:np.ndarray, \n  checkpoint_image:typing.Optional[np.ndarray]=None,\n  process_scale_factor:float=1.0, \n  output_scale_factor:float=1.0,\n  num_of_elements:int=2000,\n  batch_size:int=200,\n  num_of_retries:int=20,\n  width_divs:int=1, \n  height_divs:int=1,\n  min_alpha:int=1,\n  max_alpha:int=255,\n  max_size_start_coef:float=0.4,\n  max_size_end_coef:float=0.1,\n  max_size_decay_coef:float=1.0,\n  min_size:int=2,\n  element_type:typing.Union[ElementType, str]=ElementType.LINE,\n  tile_select_mode:typing.Union[TileSelectMode, str]=TileSelectMode.RANDOM,\n  tile_target:typing.Optional[typing.Tuple[int, int]]=None,\n  workers:int=1,\n  save_progress:bool=False,\n  progress_save_path:str=\"tmp\",\n  progress_callback:typing.Optional[typing.Callable[[np.ndarray, float], None]]=None,\n  custom_process_metrics:typing.Optional[typing.Tuple[typing.Callable[[np.ndarray, np.ndarray], float], typing.Union[MetricsMode, str]]]=None,\n  custom_evaluation_metrics:typing.Optional[typing.Tuple[typing.Callable[[np.ndarray, np.ndarray], float], typing.Union[MetricsMode, str]]]=None,\n  min_improvement: int=2000,\n  debug_on_progress_image:bool=False,\n  debug:bool=False,\n  use_tqdm:bool=False,\n  visualise_progress:bool=False\n)\n```\n\n#### Example use\n\n```python\nfrom elementarise import Elementariser, ElementType\nfrom PIL import Image\nimport numpy as np\n\nreference_image = np.array(Image.open(\"reference_image.png\", mode=\"RGB\"))\n\nelementariser = Elementariser(\n  reference_image,\n  process_scale_factor=0.5,\n  output_scale_factor=2.0,\n  num_of_elements=5000,\n  batch_size=200,\n  num_of_retries=50,\n  width_divs=2,\n  height_divs=2,\n  element_type=ElementType.CIRCLE,\n  workers=4,\n  use_tqdm=True\n)\n\noutput_image = elementariser.run()\nImage.fromarray(reference_image, mode=\"RGB\").save(\"result.png\")\n```\n\n### Script\n```\npython -m elementarise --help\n\nusage: __main__.py [-h] --input INPUT --output OUTPUT [--checkpoint CHECKPOINT] [--elements ELEMENTS] [--batch_size BATCH_SIZE] [--tries TRIES]\n                   [--element_type ELEMENT_TYPE] [--min_alpha MIN_ALPHA] [--max_alpha MAX_ALPHA] [--max_size_start_coef MAX_SIZE_START_COEF]\n                   [--max_size_end_coef MAX_SIZE_END_COEF] [--max_size_decay_coef MAX_SIZE_DECAY_COEF] [--min_size MIN_SIZE]\n                   [--tile_select_mode TILE_SELECT_MODE] [--target_tile TARGET_TILE] [--process_scale_factor PROCESS_SCALE_FACTOR]\n                   [--output_scale_factor OUTPUT_SCALE_FACTOR] [--width_splits WIDTH_SPLITS] [--height_splits HEIGHT_SPLITS] [--workers WORKERS]\n                   [--disable_visuals] [--save_progress] [--progress_folder PROGRESS_FOLDER]\n\noptions:\n  -h, --help            show this help message and exit\n  --input INPUT, -i INPUT\n                        Path to input image\n  --output OUTPUT, -o OUTPUT\n                        Path to output image\n  --checkpoint CHECKPOINT, -ch CHECKPOINT\n                        Path to checkpoint image\n  --elements ELEMENTS, -e ELEMENTS\n                        Number of elements to draw (default: 2000)\n  --batch_size BATCH_SIZE, -b BATCH_SIZE\n                        Number of elements generated to test (default: 200)\n  --tries TRIES, -t TRIES\n                        Limit number of repeats per element (default: 20)\n  --element_type ELEMENT_TYPE, -et ELEMENT_TYPE\n                        Element used for recreating reference image (default: line), line, circle, triangle, square, pentagon, hexagon, octagon, random\n  --min_alpha MIN_ALPHA\n                        Minimal alpha value (default: 1)\n  --max_alpha MAX_ALPHA\n                        Maximal alpha value (default: 255)\n  --max_size_start_coef MAX_SIZE_START_COEF\n                        Maximum size start coef (default: 0.4)\n  --max_size_end_coef MAX_SIZE_END_COEF\n                        Maximum size final coef (default: 0.1)\n  --max_size_decay_coef MAX_SIZE_DECAY_COEF\n                        Maximum size decay coef (multiplier for size translation) (default: 1)\n  --min_size MIN_SIZE   Minimum size (default: 2)\n  --tile_select_mode TILE_SELECT_MODE, -tsm TILE_SELECT_MODE\n                        Tile select mode changes behaviour of tile selection when multiple of them are present (default: random), random - tiles are\n                        selected randomly, round_robin - tiles are selected one after another, priority - tiles with worst metrics will get processed first,\n                        one_by_one - tiles will be completed one after another (not good for generating from start), target - target specific tile for\n                        processing\n  --target_tile TARGET_TILE\n                        Tile indexes for target tile select mode\n  --process_scale_factor PROCESS_SCALE_FACTOR, -psf PROCESS_SCALE_FACTOR\n                        Scale down factor for generating image (example: 2 will scale image size in both axis by factor of 2)\n  --output_scale_factor OUTPUT_SCALE_FACTOR, -osf OUTPUT_SCALE_FACTOR\n                        Scale factor for output image (same behaviour as process_scale_factor)\n  --width_splits WIDTH_SPLITS, -ws WIDTH_SPLITS\n                        Number of width splits for generating elements in smaller more specific areas (1 = no splits - default)\n  --height_splits HEIGHT_SPLITS, -hs HEIGHT_SPLITS\n                        Same as width splits only for height\n  --workers WORKERS, -w WORKERS\n                        Number of workers\n  --disable_visuals     Disable progress image output\n  --save_progress       Store progress of generation\n  --progress_folder PROGRESS_FOLDER\n                        Path to folder where progress imagis will be saved (default: tmp)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatesxs%2Felementarise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatesxs%2Felementarise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatesxs%2Felementarise/lists"}