Skip to content

kk-digital/kcg-image-tools

Repository files navigation

kcg-tiletool

Set of helping tools for cleaning image datasets and extracting patches from this set of images.

Table of Contents

There is currently 9 standalone tools in the project

GIFDatasetTools

Given a source directory containing GIF images, the tool go through all the images inside the directory and computes each image metadata saves the result into a JSON file with name images_metadata.json, and an option to extract the frames of each image and specifying a max number of frames to extract for each image.

For more info about the tool and usage instructions check this link

ImagePatchExtractor

A standalone tool for extracting patches from a set of images in a certain directory and output the output concatenation in .png format in another directory.

Given a source directory containing images, the tool checks and validates this set of images, then extract patches from those images randomly or on grid and may applies some kind of augmentation or noise addition but those are left as options to the user.

For more info about the tool and usage instructions check this link

ImageDatasetCleaner

Given a source directory containing images or compressed files depending on the value of the flag compressed_files_dir the tool applies certain conditions,

if compressed_files_dir is False the tool applies some conditions and copies the valid images into the output_directory and two json files of the status of processed images saved in the same output directory with names failed-images.json and images-info.json if write_status_files was set to True.

applied conditions are:

  • Make sure if the image file is not corrupted
  • Checks if the image format is within the given allowed image formats (codecs) provided as an option to the cli defaults are JPEG and PNG only
  • Check if the image size is withing the range of min size and max size provided by the user as an option defaults are (32,32) for min size and (16384,16384) for max size

if compressed_file_dir is True Given a source directory containing compressed files (with any type of compression) the tool applies the following steps.

  • decompress these files.
  • apply the conditions stated above (in validating images part) to the images if clean_after_decompress is True,
  • compress the cleaned directories back again if compress_after_type was set and is not None.

For more info about the tool and usage instructions check this link

ImageDatasetPreview

A standalone tool for image dataset preview.

Given a source directory containing images, the tool reads all the images in this directory scale them down to a size provided from the user and then concatenates those scaled images into a matrix shaped image with those small images as elements, and those matrix images are saved in PNG formats in the output_directory provided by the user.

For more info about the tool and usage instructions check this link

ImageUniqueColors

A standalone tool calculating the unique colors in images.

Given a source directory the tool go through all the images inside the directory and counts the number of unique colors of each image and then prints a single line for each image contains the computed number of unique pixels and the image path separated by a separator and the number of unique pixels is fixed in output length.

The tool counts unique pixels in images of any type, so it works with RGB, RGBA, gray scale images or whatever.

For more info about the tool and usage instructions check this link

ImageDatasetInfo

A standalone tool for obtaining the metadata of a given directory of images.

given a directory containing images, process all those images and write a file with the metadata (in current working directory) of those processed images, which are image_path , image_name, image_blake2b_hash, image_size_bytes , image_dims_tuple, image_dims_string and unique_colors.

For more info about the tool and usage instructions check this link

ImageTaggingTool

A standalone tool for tagging image datasets.

given an image dataset directory and the tag tasks you need to apply for this dataset, the tool runs web UI can be accessed at http://127.0.0.1:5000 with a grid of images taken from the image directory you have passed to be used for tagging depending on the task you choose, the tagged images metadata can be found in data_output_directory in json format.

For more info about the tool and usage instructions check this link

IntegerEncoder

A standalone tool for encoding integers into other chosen codes.

The tool takes in a single integer value and encodes it into a different form from the available implemented encodings methods.

Supported methods are:

  • Binary Encodings.
  • Grey code Encodings.

For more info about the tool and usage instructions check this link

TileLerp

A standalone tool for generating linear interpolation of two images given their paths, and preview for different interpolation factor.

Given paths of two images and an interpolation factor called lerp, the linear interpolation result of the both images is produced and written as .png image in the specified directory, and also an option to preview the result of interpolation between the both images for different lerp values ranges from 0 to 1 with a step depending on the specified preview_grid_size.

For more info about the tool and usage instructions check this link

Calculate OpenCV Bounding Box

This script processes JSON records from zip files, extracts bounding box details from images, and generates a modified version of the zip file with the processed data.

Install the required dependencies by running the following command:

pip install opencv-python tqdm argparse

Functionality

The script performs the following operations:

  1. It opens each zip file and loads it into memory.
  2. Filters and processes JSON files in the zip.
  3. For each image ending in the zip file, it calculates a bounding box and the distance to the image center.
  4. Updates JSON files with new information such as the bounding box dimensions, the center of the bounding box, distance to the image center, etc.
  5. Finally, it writes the updated JSON content into a file named 'open-cv-bounding-box.json', which is stored in the 'features' directory inside the same zip file.

Usage

The script accepts a command line argument --input_path, which is the path to the directory containing zip files or a single zip file to be processed. If not provided, it defaults to the current directory ('.').

For example, you can run the script as follows:

python calculate_feature_bounding_box.py --input_path=./path_to_zip_files --output_path=./output_folder_path

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6