Skip to content

Posterization and Histogram#97

Open
Karinon wants to merge 9 commits intomainfrom
feature/posterization
Open

Posterization and Histogram#97
Karinon wants to merge 9 commits intomainfrom
feature/posterization

Conversation

@Karinon
Copy link
Collaborator

@Karinon Karinon commented Feb 17, 2026

This PR introduces:

  • the possibility to posterize the current colormap to up to 32 colors
  • adds a histogram to the colormap to see the distribution. It consists of 50 bins/columns
  • When posterized, the histogram provides a tooltip for the columns to show the specific relative frequency as well as the value range

Since it is quite costly memory-wise to keep the data completely in-memory for the histogram-calculation I do some pre-binning and calculate a finer in-memory-histogram out of which I then create the coarser histograms for the website. This leads to a minor precision-loss in the histograms for the decimal places. Not sure if this should be mentioned somewhere that the numbers are not 100% precise.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds posterization and histogram visualization features to the colormap system. Posterization allows users to reduce the colormap to 2-32 discrete color levels via a slider, while the histogram overlay shows data distribution across bins. The histogram adapts to show either 50 bins (when posterization is off) or matches the posterization level count, with interactive tooltips displaying value ranges and frequencies when posterized. To manage memory efficiently, the implementation uses a pre-binning strategy with 4096-bin summaries that are dynamically rebinned for display.

Changes:

  • Added posterization support (0-32 levels) with GLSL shader implementation and UI controls
  • Implemented histogram visualization with tooltips showing value ranges and frequencies
  • Refactored histogram calculation to use memory-efficient pre-binning strategy
  • Added URL parameter synchronization for posterize levels
  • Integrated histogram updates across all grid types (Regular, Irregular, Triangular, Healpix, GaussianReduced, Curvilinear)

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/utils/urlParams.ts Added POSTERIZE_LEVELS URL parameter constant
src/utils/histogram.ts New file implementing histogram summary building, merging, and rebinning logic
src/ui/overlays/controls/ColormapControls.vue Added posterize slider UI with value 1 skipping logic
src/ui/overlays/controls/ColorBar.vue Added histogram canvas overlay, tooltip, and mid-labels for posterization
src/ui/overlays/controls/BoundsControls.vue Refactored to use computed properties for bound updates
src/ui/overlays/Controls.vue Added posterize levels initialization from URL parameters
src/ui/grids/composables/useSharedGridLogic.ts Added histogram update logic with watchers for posterize levels and bounds changes
src/ui/grids/Triangular.vue Integrated histogram calculation, refactored data distribution
src/ui/grids/Regular.vue Added histogram calculation call
src/ui/grids/Irregular.vue Refactored geographic dimension handling, added histogram calculation, removed redundant Float64Array conversion
src/ui/grids/Healpix.vue Added histogram summary building per chunk and merging
src/ui/grids/GaussianReduced.vue Added histogram calculation call
src/ui/grids/Curvilinear.vue Added histogram calculation call
src/store/useUrlSync.ts Added posterize levels URL synchronization, simplified user bounds logic
src/store/store.ts Added posterize levels and histogram state, added user bounds update actions with string handling
src/store/paramStore.ts Added posterize levels parameter mapping
src/lib/shaders/gridShaders.ts Added posterize GLSL function, integrated into all fragment shaders, added edge case handling for min==max
src/lib/shaders/colormapShaders.ts Removed unused "Quantized" colormap

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +315 to +327
// Add hover listeners for histogram
if (histogramCanvas.value) {
useEventListener(
histogramCanvas.value,
"mousemove",
handleHistogramMouseMove
);
useEventListener(
histogramCanvas.value,
"mouseleave",
handleHistogramMouseLeave
);
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The histogram tooltip is only accessible via mouse hover (mousemove/mouseleave events). Users navigating with keyboard or screen readers cannot access this information. Consider adding keyboard support (e.g., arrow keys to navigate between bins when the histogram canvas is focused) and ARIA attributes to make the tooltip information accessible to screen readers.

Copilot uses AI. Check for mistakes.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 17, 2026

Deploying gridlook with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6f3feca
Status: ✅  Deploy successful!
Preview URL: https://509d7b4a.gridlook.pages.dev
Branch Preview URL: https://feature-posterization.gridlook.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant