This project places images onto another image at random positions, sizes, rotations, and tints, to remake the target image. The goal is to find the object placement, size, rotation, and tint that is closest to the target image.
litterly that thing that spu7nix made but worse and my program only does it once
The script main.py
performs the following actions:
-
Loads Images: Loads a background image (
background_path
), a set of objects images from the/object/
folder, and tries to recreate the target image (image_path
). -
Random Transformations: For each attempt:
- Randomly selects an object image from
/object/
. - Resizes the object to a random scale (
size_min
tosize_max
). - Rotates the object by a random angle (0 to 360 degrees).
- Applies a random tint to the object.
- Places the transformed object at a random position on the image.
- Randomly selects an object image from
-
Score Calculation: Calculates a score using the
image_color_difference
function fromdif.py
, comparing the modified background image with thenew bacground image
. This function uses a colormap to visualize the differences and calculates a score based on pixel-wise color distances. -
Output: Saves each modified background image and its corresponding difference colormap to a directory named
{attempt_number}_{score}
within the/output/
folder. Also creates ahighest_score.json
file in the/output/
directory containing the attempt number and score of the highest-scoring placement.
- Python 3.12.1
- A CPU I guess
- No GPU cuz I dont have one ;-;
- Clone the repository:
git clone https://github.com/loool999/W
- Install dependencies:
pip install pillow matplotlib numpy
- Prepare your images:
- Place your background image in the
background_path
. - Place your object images (PNG format) in the
/object/
folder. - Place your target image in the
image_path
.
- Place your background image in the
- Run the script:
python main.py
- Customize: You can adjust parameters like
max_attempts
within themain.py
script.
Contributions are welcome! Please open an issue or submit a pull request.
- Uhhh more thing
- Change name
- automate the process
- make it faster
- completing the TODOs
Used MIT LICENSE cuz that one sounds pretty cool :)