diff --git a/tests/magick-image/statistics.spec.ts b/tests/magick-image/statistics.spec.ts index 7b0c95b..68b7bfe 100644 --- a/tests/magick-image/statistics.spec.ts +++ b/tests/magick-image/statistics.spec.ts @@ -30,41 +30,6 @@ describe('MagickImage#statistics', () => { }); }); - it('should return the statistics for a channel', () => { - TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => { - const statistics = image.statistics(Channels.Blue); - - let channelStatistics = statistics.getChannel(PixelChannel.Blue); - channelStatistics = expectToNotBeNull(channelStatistics); - expect(channelStatistics.channel).toBe(PixelChannel.Blue); - expect(channelStatistics.depth).toBe(8); - expect(channelStatistics.entropy).toBeCloseTo(0.80694, 4); - expect(channelStatistics.kurtosis).toBeCloseTo(-0.27825, 4); - expect(channelStatistics.maximum).toBe(255); - expect(channelStatistics.mean).toBeCloseTo(130.64240, 4); - expect(channelStatistics.minimum).toBe(2); - expect(channelStatistics.skewness).toBeCloseTo(-1.00552, 4); - expect(channelStatistics.standardDeviation).toBeCloseTo(42.70252, 4); - }); - }); - - it('should return the statistics for the composite channel', () => { - TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => { - const statistics = image.statistics(Channels.Green); - - const channelStatistics = statistics.composite(); - expect(channelStatistics.channel).toBe(PixelChannel.Composite); - expect(channelStatistics.depth).toBe(8); - expect(channelStatistics.entropy).toBeCloseTo(0.76887, 4); - expect(channelStatistics.kurtosis).toBeCloseTo(0.65771, 4); - expect(channelStatistics.maximum).toBe(255); - expect(channelStatistics.mean).toBeCloseTo(100.22261, 4); - expect(channelStatistics.minimum).toBe(1); - expect(channelStatistics.skewness).toBeCloseTo(-0.65869, 4); - expect(channelStatistics.standardDeviation).toBeCloseTo(32.03352, 4); - }); - }); - it('should return null as the statistics for a unknown channel', () => { TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => { const statistics = image.statistics(Channels.Red); diff --git a/tests/statistics/statistics/composite.spec.ts b/tests/statistics/statistics/composite.spec.ts new file mode 100644 index 0000000..5a20186 --- /dev/null +++ b/tests/statistics/statistics/composite.spec.ts @@ -0,0 +1,27 @@ +/* + Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. + Licensed under the Apache License, Version 2.0. +*/ + +import { Channels } from '@src/enums/channels'; +import { PixelChannel } from '@src/enums/pixel-channel'; +import { TestFiles } from '@test/test-files'; + +describe('Statistics#composite', () => { + it('should return the statistics for the composite channel', () => { + TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => { + const statistics = image.statistics(Channels.Green); + + const channelStatistics = statistics.composite(); + expect(channelStatistics.channel).toBe(PixelChannel.Composite); + expect(channelStatistics.depth).toBe(8); + expect(channelStatistics.entropy).toBeCloseTo(0.76887, 4); + expect(channelStatistics.kurtosis).toBeCloseTo(0.65771, 4); + expect(channelStatistics.maximum).toBe(255); + expect(channelStatistics.mean).toBeCloseTo(100.22261, 4); + expect(channelStatistics.minimum).toBe(1); + expect(channelStatistics.skewness).toBeCloseTo(-0.65869, 4); + expect(channelStatistics.standardDeviation).toBeCloseTo(32.03352, 4); + }); + }); +}); diff --git a/tests/statistics/statistics/get-channel.spec.ts b/tests/statistics/statistics/get-channel.spec.ts new file mode 100644 index 0000000..ea08031 --- /dev/null +++ b/tests/statistics/statistics/get-channel.spec.ts @@ -0,0 +1,28 @@ +/* + Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. + Licensed under the Apache License, Version 2.0. +*/ + +import { Channels } from '@src/enums/channels'; +import { PixelChannel } from '@src/enums/pixel-channel'; +import { TestFiles } from '@test/test-files'; + +describe('Statistics#getChannel', () => { + it('should return the statistics for a channel', () => { + TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => { + const statistics = image.statistics(Channels.Blue); + + let channelStatistics = statistics.getChannel(PixelChannel.Blue); + channelStatistics = expectToNotBeNull(channelStatistics); + expect(channelStatistics.channel).toBe(PixelChannel.Blue); + expect(channelStatistics.depth).toBe(8); + expect(channelStatistics.entropy).toBeCloseTo(0.80694, 4); + expect(channelStatistics.kurtosis).toBeCloseTo(-0.27825, 4); + expect(channelStatistics.maximum).toBe(255); + expect(channelStatistics.mean).toBeCloseTo(130.64240, 4); + expect(channelStatistics.minimum).toBe(2); + expect(channelStatistics.skewness).toBeCloseTo(-1.00552, 4); + expect(channelStatistics.standardDeviation).toBeCloseTo(42.70252, 4); + }); + }); +});