Skip to content

New Node: Sharpen node - #4516

Open
Zadfar wants to merge 5 commits into
GraphiteEditor:masterfrom
Zadfar:add-sharpen-filter
Open

New Node: Sharpen node#4516
Zadfar wants to merge 5 commits into
GraphiteEditor:masterfrom
Zadfar:add-sharpen-filter

Conversation

@Zadfar

@Zadfar Zadfar commented Sep 10, 2026

Copy link
Copy Markdown

This PR adds a new sharpen node to the Raster: Filter category, allowing users to sharpen images using unsharp masking.

Changes made

  • Added new sharpen node with three inputs (amount, radius and threshold)
  • Implemented sharpen_algorithm() which uses the unsharp mask technique to sharpen images
  • Made a new fn for PremultipliedGammaPixel called to_unpremultiplied_channels(), as this was required by both the sharpening algorithm and gaussian blur algorithm

Notes on implementation

  • This implementation borrows heavily from how photoshop did unsharp mask (inputs and ranges), i thought this might be more intuitive for users
  • I opted to use the gaussian blur in gamma space as this provided the output most similar to unsharp mask tools from other software.
  • There is a hard limit on the threshold variable (255), this comes from the maximum constrast difference in 8bit images
  • The soft limits of 100%, 50px and 30 for amount, radius and threshold are arbitrary and can be changed if necessary

Part of #912

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread node-graph/nodes/raster/src/filter.rs
Comment thread node-graph/nodes/raster/src/filter.rs
Comment thread node-graph/nodes/raster/src/filter.rs
Comment thread node-graph/nodes/raster/src/filter.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread node-graph/nodes/raster/src/filter.rs Outdated
Comment thread node-graph/nodes/raster/src/filter.rs Outdated
@Zadfar
Zadfar marked this pull request as draft September 11, 2026 10:20
@Zadfar
Zadfar marked this pull request as ready for review September 11, 2026 11:52

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread node-graph/nodes/raster/src/filter.rs
@TTyChud

TTyChud commented Sep 13, 2026

Copy link
Copy Markdown

the bug is on 426: from_gamma_srgb_channels() already returns an unassociated Color, so multiplying by original_a writes associated values into an Image<Color and darkens translucent pixels.

suggestion-
*original = Color::from_gamma_srgb_channels(final_r, final_g, final_b, original_a);

@Zadfar

Zadfar commented Sep 13, 2026

Copy link
Copy Markdown
Author

I have updated the code to handle the new color struct with unassociated alpha 944d00c. This also clears up the other issues in gaussian blur as well.

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.

2 participants