Image Combination with Hamming Distances

Overview

This wiki provides an overview of a Python script designed to generate and combine striking images based on Hamming distances. The script involves creating images using Latin squares, calculating Hamming distances between pairs of images, and visualizing the differences using heatmaps. Additionally, it generates a master CSV file to store information about the generated images.

Python Code

diagram (1).png

Mathematical Concepts and Operations

The script involves several interesting mathematical concepts and operations, primarily focusing on generating and combining images with a mathematical foundation. Here's an explanation of the key mathematical aspects:

1. Latin Squares

image1_f2f40975afd1c7318f5abe940c32a2a9_latin_6.png

image2_051b196e020e6e468a084fb736e05676_latin_6.png

The use of Latin squares to produce the two parent images introduces a structured and systematic approach to image generation. The consistent and diverse color patterns they introduce contribute to the distinctiveness and visual appeal of the generated images.

2. Hamming Distance

The Hamming distance is a measure of the difference between two strings of equal length. In the context of the script, it is applied to RGB pixel values of images. For each pair of corresponding pixels in two images, the Hamming distance calculates the number of positions at which the RGB values differ. This distance is then used to quantify the dissimilarity between images.

The Hamming distance is special in this context because it serves as a quantitative metric for capturing and visualizing the dissimilarity between images. It provides a nuanced understanding of how Latin squares influence the color compositions and variations in the generated images.

Let's break down the mathematical process of calculating the Hamming distance between two images based on Latin squares.

Mathematical Breakdown of Hamming Distance Calculation with Latin Squares

The Hamming distance, in this case, quantifies the dissimilarity between two images represented by Latin squares. It measures the average difference in RGB values of corresponding pixels, providing a numerical metric for image dissimilarity.

3. Image Combination

striking_image_6e56ca6c91e28349b1114ae427d1f894_latin_6_6.png

The script combines images by taking the average of corresponding pixel values from two parent images. This involves mathematical operations such as averaging the red, green, and blue components separately for each pixel. The result is a new striking image that inherits characteristics from both parent images.