cornerstone
cornerstone copied to clipboard
Get image blob data(or source data, png or jpg) from cornerstone image data
Hello there,
When I call cornerstone.loadImage(imageId) then I get image data; Is there any way to get image blob data(or source data, png or jpg) from the image data. to use it in image tag. I know after drawing(with cornerstone.displayImage) I can get the image blob from canvas. I want to get image blob data without drawing the image. I found image.getPixelData(). Can I use this function to get image blob data? Could anyone help me with that issue, please?
Thank you in advance.
I am facing a similar issue too. I'm looking to send the image blob to a post request. Did you find any solution?
According to cornerstone's image documentation, there's a function called getImage() that describes the same thing you want. I also tried it, but I get an error that there's no such function in existence.
The solution I found is using image.getPixelData() function. I can get raw data of pixels. I should convert it to 0~255 RGB data. I'm now sure whether this is the best solution.
If you're running orthanc for your database, they have an API to get the image png if you give them an instance id. I'm not sure at the moment of how you can access. here's a link for their api documentation - https://docs.google.com/spreadsheets/d/e/2PACX-1vSBEymDKGZgskFEFF6yzge5JovGHPK_FIbEnW5a6SWUbPkX06tkoObUHh6T1XQhgj-HqFd0AWSnVFOv/pubhtml?gid=986690746&single=true
any updates on this? really want to load the raw image pixel data into png..
Hello! If you want to get the blob, all you have to do is:
const activeEnabledElement = cornerstone.getEnabledElements()[0]
cornerstone.loadImage(activeEnabledElement.image.imageId).then(image => {
const imageBlob = image.getCanvas().toDataURL('image/png');
});
This won't work unless the image is a color image