image-js / image-js-typescript

Temporary repository to work on the migration of image-js to TypeScript
https://image-js.github.io/image-js-typescript/
MIT License
5 stars 5 forks source link

check if hypotenuse options are implemented correctly #406

Closed EscapedGibbon closed 9 months ago

EscapedGibbon commented 9 months ago
test('testing with rgb image', () => {
  const image = testUtils.createRgbImage([[3, 5, 8]]);
  const otherImage = testUtils.createRgbImage([[4, 12, 15]]);

  const expected = testUtils.createRgbImage([[5, 13, 17]]);
  expect(image.hypotenuse(otherImage, { channels: [0] })).toMatchImage(
    expected,
  );
});

when applying hypotenuse only to one channel, I believe this test should not pass, yet it does.

stropitek commented 9 months ago

Can you explain what you would expect to happen in this test case?

Are those expectations consistent with what happens in other methods that have the channels option?

EscapedGibbon commented 9 months ago

Can you explain what you would expect to happen in this test case?

channels option specifies which channels the algorithm should be applied to. So, in this case, it should return [5,5,8] and not [5,13,17]. I checked it now and, somehow, this test works correctly, but if you put [0,1] in channels options, it will still apply hypotenuse on all channels instead of channels 0 and 1.

EscapedGibbon commented 9 months ago

Are those expectations consistent with what happens in other methods that have the channels option?

I believe so if I understand what applying the algorithm to specific channels means correctly. There is also channel option in level function, and I think it works correctly there.

stropitek commented 9 months ago

I believe so if I understand what applying the algorithm to specific channels means correctly. There is also channel option in level function, and I think it works correctly there.

Can you point me to a test that uses this option for the level or another method?

EscapedGibbon commented 9 months ago

I believe so if I understand what applying the algorithm to specific channels means correctly. There is also channel option in level function, and I think it works correctly there.

Can you point me to a test that uses this option for the level or another method?

https://github.com/image-js/image-js-typescript/blob/3a9bc791c86cc19f54a738a03221ea9dfac3724f/src/filters/__tests__/level.test.ts#L74

EscapedGibbon commented 9 months ago

https://github.com/image-js/image-js-typescript/blob/3a9bc791c86cc19f54a738a03221ea9dfac3724f/src/filters/__tests__/level.test.ts#L95

stropitek commented 9 months ago

Thanks, indeed seems like a bug. You can go ahead and implement a fix