Skip to content

Fixes numerical issues with N0f8 types#65

Merged
zygmuntszpak merged 6 commits into
masterfrom
n0f8
Apr 27, 2026
Merged

Fixes numerical issues with N0f8 types#65
zygmuntszpak merged 6 commits into
masterfrom
n0f8

Conversation

@zygmuntszpak
Copy link
Copy Markdown
Member

Fixes #64

Another issue that arose is that we try to simultaneously support canonical JuliaImages image types, as well as the ability to pass in a matrix of raw numbers. Using the function gray on a raw number throws an error. I've refactored some key lines so that gray is only utilised on JuliaImages types.

@mkitti mkitti requested a review from Copilot April 23, 2026 06:22
Copy link
Copy Markdown

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

Adds regression coverage around Contrast Limited Adaptive Histogram Equalization (CLAHE) to prevent conversion errors on fixed-point grayscale images and to ensure raw numeric arrays are supported (per issue #64).

Changes:

  • Add a CLAHE regression test for Gray{N0f8} inputs (issue #64).
  • Add a CLAHE test ensuring UInt8 matrices are handled without conversion failures and preserve UInt8 output.

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

Comment thread test/adaptive_equalization.jl Outdated
# https://github.com/JuliaImages/ImageContrastAdjustment.jl/issues/64
rng = StableRNG(123)
# A sufficiently large random image would previously trigger the same issue as reported above
img = Gray{N0f8}.([only(rand(rng,1)) for r = 1:600, c = 1:600])
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in latest push

Comment thread test/adaptive_equalization.jl Outdated
Comment on lines +133 to +134
@test minimum(imgeq) >= Gray{N0f8}(0)
@test maximum(imgeq) <= Gray{N0f8}(1)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I do this instead now:

    minval = 0
    maxval = 1
    algo = AdaptiveEqualization( nbins = 256, minval = minval, maxval = maxval, rblocks = 4, cblocks = 4, clip = 0.2)
    imgeq = adjust_histogram(img, algo)
    @test minimum(imgeq) >= Gray{N0f8}(minval)
    @test maximum(imgeq) <= Gray{N0f8}(maxval)
 

Another issue that arose is that we try to simultaneously support canonical JuliaImages image types, as well as the ability to pass in a matrix of raw numbers. Using the function `gray` on a raw number throws an error. I've refactored some key lines so that gray is only utilised on JuliaImages types.
@zygmuntszpak
Copy link
Copy Markdown
Member Author

It's been too long since I last committed to the ecosystem, so I am out of the loop regarding the CI. Need to investigate how to get them working again.

Error: This request has been automatically failed because it uses a deprecated version of actions/cache: v1. Please update your workflow to use v3/v4 of actions/cache to avoid interruptions. Learn more: https://github.blog/changelog/2024-12-05-notice-of-upcoming-releases-and-breaking-changes-for-github-actions/#actions-cache-v1-v2-and-actions-toolkit-cache-package-closing-down

@zygmuntszpak
Copy link
Copy Markdown
Member Author

@timholy @johnnychen94 Its been a while since I had the capacity to contribute to the ecosystem, so I'm a bit out of touch with the current protocol for reviewing, merging, tagging and releasing.

Copy link
Copy Markdown
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

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

Looks great to me! Very clean changes. (except that I would use <name>/<feat_name> rather than n0f8 as the branch name :P )

To make a release, just make a comment at the release commit with @JuliaRegistrator register should be okay, I believe (https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app)

@zygmuntszpak zygmuntszpak merged commit a85169c into master Apr 27, 2026
11 checks passed
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.

AdaptiveEqualization may fail on N0f8 images

3 participants