Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 661e66b

Browse files
authored
feat: add static method fromMask to RoiMapManager (#289)
1 parent 5076c62 commit 661e66b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/roi/RoiMapManager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Matrix } from 'ml-matrix';
22

3+
import { Mask } from '../Mask';
4+
35
import { Roi } from './Roi';
6+
import { FromMaskOptions, fromMask } from './fromMask';
47
import { getRois, GetRoisOptions } from './getRois';
58

69
export interface RoiManager {
@@ -79,4 +82,8 @@ export class RoiMapManager implements RoiManager {
7982
public getRois(options: GetRoisOptions = {}): Roi[] {
8083
return getRois(this, options);
8184
}
85+
86+
public static fromMask(mask: Mask, options: FromMaskOptions = {}) {
87+
return fromMask(mask, options);
88+
}
8289
}

src/roi/__tests__/RoiMapManager.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { RoiMapManager } from '../RoiMapManager';
12
import { fromMask } from '../fromMask';
23

34
test('should work with crop', () => {
@@ -25,4 +26,14 @@ test('should work with crop', () => {
2526
[0, 200, 0],
2627
[225, 250, 200],
2728
]);
29+
30+
const roiMapManager2 = RoiMapManager.fromMask(mask);
31+
const rois2 = roiMapManager2.getRois();
32+
33+
const result2 = image.crop(rois2[0]);
34+
35+
expect(result2).toMatchImageData([
36+
[0, 200, 0],
37+
[225, 250, 200],
38+
]);
2839
});

0 commit comments

Comments
 (0)