-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f55996
commit eb38214
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
import { Channels } from '../../src/channels'; | ||
import { ErrorMetric } from '../../src/error-metric'; | ||
import { Percentage } from '../../src/percentage'; | ||
import { TestImages } from '../test-images'; | ||
|
||
describe('MagickImage#threshold', () => { | ||
it('should threshold the image with the correct default values', () => { | ||
TestImages.Builtin.logo.use((image) => { | ||
image.clone((other) => { | ||
image.threshold(new Percentage(80)); | ||
other.threshold(new Percentage(80), Channels.Undefined); | ||
|
||
const difference = other.compare(image, ErrorMetric.RootMeanSquared); | ||
expect(difference).toBe(0); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should threshold the image', () => { | ||
TestImages.Builtin.logo.use((image) => { | ||
image.clone((other) => { | ||
image.threshold(new Percentage(80)); | ||
|
||
const difference = other.compare(image, ErrorMetric.RootMeanSquared); | ||
expect(difference).toBeCloseTo(0.165); | ||
}); | ||
}); | ||
}); | ||
}); |