How to load a bitmap segmentation using cornerstone segmentation and brush tool?

486 Views Asked by At

I'm trying to load a 2d bitmap that involves some segmentation information regarding a study and would like to use the available tools to do so. While going through documents I can't find any discrete example to achieve this. Anyone has any idea of doing it with cornerstoneTools.

1

There are 1 best solutions below

0
On

You should use cornerstoneTools >= 4.0 version for that. As you can see in this issue, Labelmap Renderer is already implemented from here. Maybe, you should also look at the cornerstoneWebImageLoader repository.

Then, you can do as follows:

cornerstone.loadImage(imageId).then(image => {
cornerstone.displayImage(element, image);

cornerstoneTools.mouseInput.enable(element);
cornerstoneTools.mouseWheelInput.enable(element);
...
}).then(() => {
    let pixelData = new Uint8ClampedArray(width * height * channel);
    for (let i = 128; i < 256; i++) {
        for (let j = 256; j < 384; j++) {
            pixelData[i*width + j] = 1;
        }
    }
    ...
    cornerstone.updateImage(element);
});