# sathviktr/seam_carving architecture

> Architecture diagram of the GitHub repository sathviktr/seam_carving, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sathviktr/seam_carving
- Repository: https://github.com/sathviktr/seam_carving

## Overview

This is a command-line seam-carving image resizer. The user supplies an image path and smaller target dimensions; the program loads the image, computes pixel energy, repeatedly finds and removes minimum-energy vertical and horizontal seams, and displays the resizing animation. The seam search uses dynamic programming. All runtime behavior is in Q1.cpp; the README documents image reading and visualization through OpenCV. The graph reflects the sampled source, with no separate saved-image output shown.

Main entry points: [`Q1.cpp`](https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp) (Resize workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and loading"]
  node_main["Resize workflow<br/>[Q1.cpp]"]
  node_opencv["OpenCV image I/O"]
end

subgraph group_algorithm["Seam carving"]
  node_energy["Energy gradient<br/>[Q1.cpp]"]
  node_vertical["Vertical seam search<br/>[Q1.cpp]"]
  node_remove_vertical["Remove vertical seam<br/>[Q1.cpp]"]
  node_horizontal["Horizontal seam search<br/>[Q1.cpp]"]
  node_remove_horizontal["Remove horizontal seam<br/>[Q1.cpp]"]
end

subgraph group_display["Visualization"]
  node_display["Image display"]
end

node_user(("User"))
node_image["Source image"]
node_viewer(("Display window"))

node_user -->|"enters path and dimensions"| node_main
node_image -->|"provides image file"| node_opencv
node_main -->|"loads image"| node_opencv
node_main -->|"computes energy"| node_energy
node_energy -->|"returns energy map"| node_main
node_main -->|"finds vertical seam"| node_vertical
node_main -->|"removes vertical seam"| node_remove_vertical
node_main -->|"finds horizontal seam"| node_horizontal
node_main -->|"removes horizontal seam"| node_remove_horizontal
node_main -->|"shows resizing frames"| node_display
node_display -->|"renders frames"| node_viewer

click node_main "https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp"
click node_energy "https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp"
click node_vertical "https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp"
click node_remove_vertical "https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp"
click node_horizontal "https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp"
click node_remove_horizontal "https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_opencv,node_user toneBlue
class node_energy,node_vertical,node_remove_vertical,node_horizontal,node_remove_horizontal toneAmber
class node_display toneMint
class node_image,node_viewer toneIndigo
```

## Components

### Input and loading

- [Resize workflow](https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp): `Q1.cpp`
- **OpenCV image I/O**

### Seam carving

- [Energy gradient](https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp): `Q1.cpp`
- [Vertical seam search](https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp): `Q1.cpp`
- [Remove vertical seam](https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp): `Q1.cpp`
- [Horizontal seam search](https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp): `Q1.cpp`
- [Remove horizontal seam](https://github.com/sathviktr/seam_carving/blob/main/Q1.cpp): `Q1.cpp`

### Visualization

- **Image display**

### Other components

- **User**
- **Source image**
- **Display window**

## Connections

- User → Resize workflow: enters path and dimensions
- Source image → OpenCV image I/O: provides image file
- Resize workflow → OpenCV image I/O: loads image
- Resize workflow → Energy gradient: computes energy
- Energy gradient → Resize workflow: returns energy map
- Resize workflow → Vertical seam search: finds vertical seam
- Resize workflow → Remove vertical seam: removes vertical seam
- Resize workflow → Horizontal seam search: finds horizontal seam
- Resize workflow → Remove horizontal seam: removes horizontal seam
- Resize workflow → Image display: shows resizing frames
- Image display → Display window: renders frames
