Skip to content

FEAT: Add ImageNoiseConverter (random pixel noise) - #4432

Merged
Roman Lutz (romanlutz) merged 7 commits into
microsoft:mainfrom
khushi-git-7:feat/4399-image-noise-converter
Nov 24, 2026
Merged

Roman Lutz (romanlutz) merged 7 commits into
microsoft:mainfrom
khushi-git-7:feat/4399-image-noise-converter

Conversation

@khushi-git-7

@khushi-git-7 Khushi (khushi-git-7) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds ImageNoiseConverter, which adds zero-mean Gaussian pixel noise to an image to check how robust a multimodal target's image understanding and image-based safety filtering are. Closes #4399.

  • Subclasses BaseImageToImageConverter; standard_deviation (0-255 scale, default 25.0) must be finite and greater than 0, otherwise ValueError.
  • Noise is added to every color channel and clipped to 0-255; an alpha channel is left unchanged and the size is preserved. Non-RGB inputs go through _convert_to_rgb_or_rgba.
  • The generator is np.random.default_rng(get_random_seed(stream="image-noise")), following AudioWhiteNoiseConverter, so a configured seed gives identical output and the global NumPy state is untouched.
  • Exported from pyrit.converter, with a section in 3_image_converters after ImageRotationConverter, and the converter table in 0_converters updated.
  • An RGB image with a transparent color key is converted to RGBA first, so its transparency is kept as alpha instead of being lost when the noise changes the key color.

Copilot AI 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.

🟡 Changes recommended

Three new async tests omit the mandatory _async suffix required by the repository's style guide.

1 open issue
What changed in this PR

Adds ImageNoiseConverter to PyRIT’s image-conversion pipeline for testing multimodal robustness with reproducible Gaussian pixel noise, addressing #4399.

Changes:

  • Implements configurable noise with validation, seeded randomness, clipping, and alpha preservation.
  • Exports the converter and adds usage documentation and a modality-table entry.
  • Adds unit tests for noise behavior, reproducibility, image modes, and input/output handling.
File Description
tests/​unit/​converter/​test_image_noise_converter.py Tests validation, noise behavior, reproducibility, and image handling.
pyrit/​converter/​image_noise_converter.py Implements the Gaussian pixel-noise converter.
pyrit/​converter/​__init__.py Adds lazy export and type-checking import.
doc/​code/​converters/​3_image_converters.py Adds a converter explanation and usage example.
doc/​code/​converters/​0_converters.ipynb Adds the converter to the rendered modality table.

Review effort: Balanced

…onverter

Any image transform that changes pixel values needs an RGB color key promoted
to an alpha channel before transforming, so share the promotion as a base-class
helper instead of keeping it inline in ImageNoiseConverter. Converters that
only move pixels do not need it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts:
#	doc/code/converters/0_converters.ipynb
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 24, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into microsoft:main with commit fb61d45 Nov 24, 2026
66 checks passed
@khushi-git-7

Copy link
Copy Markdown
Contributor Author

Thanks for the review, for re-queuing it after the Windows runner hiccup, and for the merge, Roman Lutz (@romanlutz).

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.

FEAT: Add ImageNoiseConverter (random pixel noise)

3 participants