Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom threshold #14

Open
skyweb07 opened this issue Nov 30, 2017 · 4 comments
Open

Custom threshold #14

skyweb07 opened this issue Nov 30, 2017 · 4 comments

Comments

@skyweb07
Copy link
Owner

Allow passing a custom error threshold

@skyweb07
Copy link
Owner Author

@ralfebert
Copy link

Also having this issue, CoreGraphics seems to render non-deterministic when it comes to anti aliasing, at least I get pixel values off +/- 1 or 2 with the exact same code.

Currently I use a custom compare operation via CIImage that might be a starting point, although it doesn't seem to be particularly fast: https://gist.github.com/ralfebert/4c69b264cd374c91d28ba6b54ab1062f

@skyweb07
Copy link
Owner Author

mmm thanks for the code @ralfebert, I'll take a deeper look into this, seems that it's a little slow but I think we can speed it up a little, I'll try to hack something and come back with the results, thanks again!!

@ralfebert
Copy link

The quickest way seems to be just to compare the bytes manually:

    let d1 = referenceImageContext.data!
    let d2 = imageContext.data!
    for i in 0..<referenceImageSizeBytes {
        let b1 = d1.load(fromByteOffset: i, as: UInt8.self)
        let b2 = d2.load(fromByteOffset: i, as: UInt8.self)
        if b1 != b2 {
            let diff = abs(Int(b1) - Int(b2))
            if diff > tolerance {
                throw CompareError.notEquals
            }
        }
    }

Doesn't seem to be particularly slow...

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

No branches or pull requests

2 participants