cornerstonejs / cornerstoneWADOImageLoader

[DEPRECATED] DICOM WADO Image Loader for the cornerstone library
MIT License
280 stars 267 forks source link

Generating PNG Export through pixelData #495

Closed Lmpirk closed 1 year ago

Lmpirk commented 1 year ago

Hello, I have been trying to export the pixel data of the dcm images i read into my script to png with no success.

My goal is to be able to split a multiframe dicom in multiple png files but when i try to save the data by creating a new blob the png files generated claims that the format is not supported.

This is the function i use in order to get the pixel data:

const calculateImages = async imageId => {
        let imageArrayData = [];

        const imageFrames = await cornerstone.loadImage(imageId).then(image => {
            return image.data.string("x00280008");
        });

        for (let i = 0; i < imageFrames; i++) {
            const imageData = await cornerstone.loadImage(imageId + `?frame=${i}`).then(image => {
                let blob = new Blob([image.getPixelData()], { type: "image/png"});
                imageArrayData[i] = blob;
            });
        }

        return imageArrayData;
    };

I do not know if the methodology is wrong but i cannot seems to find a workaround.