Katkat

Generate outputs for images and pipelines

AnthropicSoftware Engineer · Technical Screen

Last updated

This question evaluates algorithmic and systems engineering skills related to batch image processing, parallelization, I/O versus CPU trade-offs, and deterministic output association within the Coding & Algorithms domain.

You are given m input images and n processing pipelines.

  • Each pipeline is an ordered list of k operations (e.g., resize, rotate, crop, blur, color transform).
  • Applying a pipeline to an image produces a new output image.

Task

Write a function/program that produces m × n output images by applying every pipeline to every input image.

Requirements

  • Each output should be associated with (image_id, pipeline_id).
  • The pipeline operations must be applied in order.
  • Assume images are stored as file paths; pipelines are provided as callable operations.
  • Your implementation should be structured so it can be parallelized easily (e.g., avoid unnecessary repeated work such as reading the same image multiple times).

Input/Output (one reasonable interface)

  • Input:
  • image_paths: List[str] (size m)
  • pipelines: List[List[Callable[[Image], Image]]] (size n, each of length k)
  • output_dir: str
  • Output:
  • Write m*n images to output_dir with deterministic names like img{idx}_pipe{j}.png, or return a list of output file paths.

Constraints (assume)

  • m, n can be large enough that runtime and I/O efficiency matter.
  • Operations may be CPU-bound; image decoding/encoding is I/O-bound.

Follow-up discussion (no need to implement)

  • How would you scale this for large m and n?
  • What parallelization strategy would you choose and why?