Skip to content

Simple (and very unoptimized) python program, that converts images into an image made out of many little cat images. I think you can only use input images with a heigth and width that is dividable by 100.

Notifications You must be signed in to change notification settings

Schlafhase/img2cat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Welcome to the img2cat documentation!

How to use the Function

The function create_mosaic takes 6 arguments:

  • img: The Image you want to convert as a numpy array
  • images_tuple: A tuple created by giving the create_img_array function the filepath of your (cat) images and the size you want them to be
  • resolution: How much the input image gets pixelated (Higher values result in a lower quality)
  • cat_size: How big one (cat) image should be (Should be the same as in the create_img_array function for best results)
  • accuracy: Determines how random the images are (When set to 1 or lower gives an error for some reason) (Set to 2 for the most accurate image)
  • saveto: The filepath you want to save the result to

Example:

import cv2
import cat_image_mosaic

cats_filepath = "./cat_images"

cat_images = cat_image_mosaic.create_img_array(images_filepath=cats_filepath, img_size=25)
im = cat_image_mosaic.read_image("input6.png") #You can also use cv2.imread() but you'll have to keep in mind that cv2.imread() reads the image in BGR by default, while the create_mosaic() function works with RGB

cat_image_mosaic.create_mosaic(img=im, images_tuple=cat_images, resolution=75, cat_size=25, accuracy=5, logs=True)

I used a public dataset with 9000 cat images for the example (https://www.kaggle.com/datasets/crawford/cat-dataset)

Input Image:

input6

Output Image: (The colors are reversed because I accidentaly used cv2.imread()) image

About

Simple (and very unoptimized) python program, that converts images into an image made out of many little cat images. I think you can only use input images with a heigth and width that is dividable by 100.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages