Skip to content
Back to skills

Cumulative Sum Channel

ASecurity

Add a cumulative sum channel along the vertical axis to capture directional structural trends in grayscale images for segmentation

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
datapython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill cumulative-sum-channel --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cumulative Sum Channel?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cumulative Sum Channel
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-cumulative-sum-channel/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-cumulative-sum-channel)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cv-cumulative-sum-channel
description: Add a cumulative sum channel along the vertical axis to capture directional structural trends in grayscale images for segmentation
---

# Cumulative Sum Channel

## Overview

For images with directional structure (seismic sections, depth profiles, medical slices), a cumulative sum along the vertical axis encodes positional context that a CNN would otherwise need many layers to learn. Mean-subtract first to center around zero, then cumsum to create a gradient-like channel that captures trends. Normalize by standard deviation to keep values in a stable range.

## Quick Start

```python
import numpy as np

def add_cumsum_channel(img, border=5):
    center_mean = img[border:-border, border:-border].mean()
    csum = (img.astype(np.float32) - center_mean).cumsum(axis=0)
    csum -= csum[border:-border, border:-border].mean()
    csum /= max(1e-3, csum[border:-border, border:-border].std())
    return csum

# Stack as additional channel
images_2ch = np.zeros((N, H, W, 2), dtype=np.float32)
for i in range(N):
    images_2ch[i, ..., 0] = images[i].squeeze() / 255.0
    images_2ch[i, ..., 1] = add_cumsum_channel(images[i].squeeze())
```

## Workflow

1. Compute center-region mean of grayscale image (exclude border pixels)
2. Subtract mean and compute cumulative sum along vertical axis
3. Re-center and normalize by center-region standard deviation
4. Stack as additional input channel alongside the original image

## Key Decisions

- **Border exclusion**: ignores edge artifacts when computing statistics
- **Vertical axis**: captures top-to-bottom structure; use `axis=1` for horizontal
- **Normalization**: prevents cumsum values from dominating pixel values in the network
- **When useful**: seismic data, depth profiles, cross-section images — any domain with vertical gradients

## References

- [UNet with depth](https://www.kaggle.com/code/bguberfain/unet-with-depth)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…