005 - Pixels & Patterns: A Photography + Python Experiment

This week I’m mixing photography with code to uncover the hidden rhythms inside my images. A small experiment with big surprises.

Hello dear reader!

Welcome to another issue of this newsletter. This week I want to talk about running experiments in photography, especially on combining photography with Python. To break up the text, I’ll include some photos from the archive.

In this issue:

  • Experimenting with photography and Python
  • Photographies from the archive

Today I’m building a bridge between photography, software development, and cities. I want to explore how photography lets us capture an instant of life in a city and then, using a bit of software, abstract the image to its minimum.

For some time, and while building PostFlow, I’ve been thinking about the data encapsulated in a photo—the decisions we make as photographers—and how those choices get embedded in a single image or in a body of work. From orientation to color (or the absence of it) and other properties, every photograph isn’t just a story being told, but also a collection of micro-decisions made by the photographer.

Having that in mind I decided to build a simple experiment to answer the question: What would my photo looked like if the pixels were compressed along the longitudinal edge? In other words, what’s the rhythm of the image from left to right?

To answer it, I built a script to analyze my photos. It’s a simple python program that takes a photo, iterates over every pixel in the X-axis, and calculates the average color of all pixels along the Y-axis. Then, it builds a new image. A sequence of pixels that reveals a unique rhythm.

from PIL import Image
import numpy as np
from pathlib import Path


def make_color_strip(input_path: str, output_path: str):
    # Load image
    img = Image.open(input_path).convert("RGB")
    arr = np.array(img)

    # Compute average color per column
    avg_colors = arr.mean(axis=0).astype(np.uint8)

    # Create strip: height = 150px for visibility
    height = 150
    width = arr.shape[1]
    strip = np.zeros((height, width, 3), dtype=np.uint8)

    for x in range(width):
        strip[:, x] = avg_colors[x]

    # Save output
    Image.fromarray(strip).save(output_path)
    print(f"Color strip saved to {output_path}")


if __name__ == "__main__":
    images_dir = Path("images")
    for img_file in images_dir.iterdir():
        if img_file.suffix.lower() in [".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".webp"]:
            output_file = img_file.with_name(f"{img_file.stem}_color_strip.png")
            make_color_strip(img_file, output_file)

When we see the strips, they reveal different patterns. In some cases, a sequence of colors; in others, the dominance of a single tone or just a subtle detail. One question I want to keep exploring is about the colors and patterns I consciously or unconsciously decide to capture in my photography.

14 images compressed.

I was inspired to try this experiment after learning about the work of Adam Magyar, especially his series Urban Flow, in which he used a high-speed camera to capture a single strip of light and condense the passing of time. In his case, he captured movement and blurred static elements. I took his work as inspiration to build these strips. To emphasize the changes captured in a photograph.

As I evolve my photography practice, I aim to introduce new ways of seeing and experimenting with my photos, and with my approach to photography. Keep experimenting, keep learning.

What do you think? What are some subtle changes you’d like to capture? Or experiments you’d like to try with your creative habits? Leave a comment; I would love to hear from you.


That’s it for today! If you enjoyed this issue, share it with a friend! Know someone experimenting with photography? Send it their way, it might inspire them too.

Luis

Tag along and stay up to date!

Become a member, and get the latest news, updates, photo essays, and more delivered straight to your inbox.

Oops! There was an error sending the email, please try again.

Awesome! Now check your inbox and click the link to confirm your subscription.