Comments (4)
.loadImage()
expects to receive an imageId that it can use to find an image (on the web [hence webImageLoader]) to create an imageObject that can be loaded into cornerstone. For cornerstoneWebImageLoader
, that format is usually something like:
As you're passing in a unique ID that can be used as a key for an image, passing the image data itself may be a bit extreme (that's a huge ID!). Instead, it might make more sense to do something like:
myLocalImageStore:
myLocalImages = [
{
id: 'unique-id-1',
base64Data: 'data:image/png;base64,...'
},
{
id: 'unique-id-2',
base64Data: 'data.image/png;base64...'
}
]
And then register a custom loader that can load images from that store:
cornerstone.registerImageLoader('myLoaderPrefix', myCustomLocalImageLoader.loadImageMethod);
And then load your images like so:
const imageId = 'myLoaderPrefix:unique-id-1';
cornerstone.loadImage(imageId ).then(image => {
// more code
});
Under the hood, your customeLocalImageLoader
should be able to:
- Find your image data in your local store
- Use the found image with some/most of the existing
cornerstoneWebImageLoader
logic to create a newimage
object for Cornerstone.
tl;dr
- I don't think what you're trying to accomplish is currently supported.
- It would not take a ton of code to add what you're looking for, but it would take some custom code.
- An easier solution might be to provide a way to receive your image from a webUrl in a
.png
or.jpeg
format so you can leverage existing code without modification
from cornerstonewebimageloader.
Awesome! Sadly we host all of our images on a server hard drive, so it would be too much to host them, considering some files are over a gig each... Anyways, I got that all setup, but I am getting errors and having other issues.
So first off. Is this loader correct for what I want to do?
public loadImage(imageId) {
const canvas = document.createElement('canvas');
const width = 256;
const height = 256;
canvas.width = width;
canvas.height = height;
const canvasContext = canvas.getContext('2d');
const imageData = canvasContext.createImageData(width, height);
const pixelData = imageData.data;
const rnd = Math.round(Math.random() * 255);
let index = 0;
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
pixelData[index++] = (x + rnd) % 256; // RED
pixelData[index++] = 0; // GREEN
pixelData[index++] = 0; // BLUE
pixelData[index++] = 255; // ALPHA
}
}
canvasContext.putImageData(imageData, 0, 0);
function getPixelData() {
return pixelData;
}
function getImageData() {
return imageData;
}
function getCanvas() {
return canvas;
}
const image = {
imageId: imageId,
minPixelValue: 0,
maxPixelValue: 255,
slope: 1.0,
intercept: 0,
windowCenter: 128,
windowWidth: 255,
render: cornerstone.renderWebImage,
getPixelData: getPixelData,
getImageData: getImageData,
getCanvas: getCanvas,
rows: height,
columns: width,
height: height,
width: width,
color: true,
columnPixelSpacing: 1.0,
rowPixelSpacing: 1.0,
invert: false,
sizeInBytes: width * height * 4
};
return {
promise: new Promise((resolve) => resolve(image)),
cancelFn: undefined
};
}
Second, I register the loader like this:
cornerstone.registerImageLoader('imageLoader', this._vs.loadImage);
Third, is this right?
cornerstone.loadImage(imageId).then(image => {
cornerstone.displayImage(imageDiv, image);
});
or am I supposed to do this._vs.loadImage(imageId)
?
from cornerstonewebimageloader.
@joshuaballas I met the same problem with you. How did you solve it ?
from cornerstonewebimageloader.
any one please help me for load TIFF images using cornerstoneWebImageLoader
from cornerstonewebimageloader.
Related Issues (20)
- ment
- 0.7.2 tag should be deleted HOT 1
- Add loadFileRequest and fileManager infrastructure HOT 2
- issues when loading a png (corruption?) HOT 2
- Associating image metaData HOT 2
- Readme includes instructions for building/running w/ Grunt, but project appears to use webpack HOT 1
- Package import issue HOT 4
- Loading from relative paths HOT 4
- 404 of cornerstoneWebImageLoader HOT 3
- Applying Filters on Images loaded HOT 1
- wen WebImageLoader wwwc not correct work HOT 1
- metaDataProvider imagePlaneModule get pixelSpacing
- Remove reference to dist/ from readme.md HOT 2
- Unable to load static jpeg image HOT 10
- Reference line functionality not working
- can this work with cornerstoneTools 4.x.x
- PNG colormap example
- IE 11 InvalidStateError when setting xhr.responseType.
- Version Issue HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cornerstonewebimageloader.