The goal is to be implemented in client side (if it's possible!) but thanks for the suggestion Leonardo. I use a 64bit linux distro with 64bit Google Chrome for the development. My laptop it uses in idle about 1GB of 3,8 available so when i run it and it peaks at about 85% it crashes. About my code
file cornerstoneFileImageLoader.js
function LoadImage(imageid)
....
....
imagePromise.then(function(image) {
imgHeight = image.height;
imgWidth = image.width;
deferred.resolve(image);
}, function() {
deferred.reject();
});
//my own function
parsePixel(imageId);
Everytime the LoadImage runs the function parsePixel runs
var parsePixelCounter = 0;
var allPixels = []; //global outside of any function maybe the garbage collection does not catch it.
function parsePixel(imageId){
var numpixels = imgWidth * imgHeight;
// It takes the dicom number out of the string
if (imageId.length > 13) {
var dcmId = imageId.slice(12, imageId.length).toString();
parsePixelCounter += 1 ;
} else {
var dcmId = imageId.slice(-1);
parsePixelCounter += 1;
}
allPixels[allPixels.length] = cornerstone.getStoredPixels(globalElement, 0, 0, imgWidth, imgHeight);
//globalElement is a global variable from the html
if (numb_of_dcm === parsePixelCounter){
....
....
Then starts the pixel iteration but the problem is in the allPixels array.