Juan,
I am currently trying to write a script that does a number of image operations such as assign(), cropTo(), apply(...,add). According to PI, the images have the following characteristics:
- Canon 40D RAWs
- width/height: 3908/2602
- Channels: 3
- Datatype: i16
- size 58 MBytes (also matches the observations in the Windows task managers)
The memory consumption for the script editor or the PJSR compile&run, script GUI etc. seem to be neglidgible, but when the script executes, memory consuption explodes to 500 MBytes, and consequenty, PI gives up:
CcdParamsEngine.doFlat() entry
CcdParamsEngine.doImages() entry
CcdParamsEngine.doImages() image1.width, image1.height=3908,2602
CcdParamsEngine.doImages() image2.width, image2.height=3908,2602
CcdParamsEngine.doImages() sumImage.width, sumImage.height=0,0
CcdParamsEngine.doImages() sumImage.width, sumImage.height=0,0
CcdParamsEngine.computeTargetRect(),lengthFactor=0.1
CcdParamsEngine.computeTargetRect(),x0,x1,y0,y1=1758.6,2149.4,1170.9,1431.1000000000001
CcdParamsEngine.doImages() assign(Image1)
CcdParamsEngine.doImages() cropTo()1
CcdParamsEngine.doImages() assign(Image2)
CcdParamsEngine.doImages() cropTo()2
CcdParamsEngine.doImages() assign(cropped1)1
Basic CCD Params Script done
*** Error [000]: C:/PCLGeorg/scripts/BasicCameraParameters.js, line 251: out of memory
Could you have a look at the code snippet attached below, to see what is going wrong there. What I am trying to do is to cut 10% of the central image region, and later do some statistical operations on that.
Thanks!
Georg
this.computeTargetRect=function(image, lengthFactor){
var width=image.width;
var height=image.height;
var newWidth=width*lengthFactor;
var newHeight=height*lengthFactor;
var targetRect=new Rect(newWidth,newHeight);
targetRect.moveTo((width-newWidth)/2,(height-newHeight)/2);
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.computeTargetRect(),lengthFactor=",lengthFactor);
console.writeln("CcdParamsEngine.computeTargetRect(),x0,x1,y0,y1=",
targetRect.x0,",",targetRect.x1,",",targetRect.y0,",",targetRect.y1);
} // if debugging
return targetRect;
} //computeTargetRect()
//compute derived images sumImage, diffImage
this.doImages=function(image1, image2, lengthFactor, sumImage, diffImage){
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.doImages() entry");
console.writeln("CcdParamsEngine.doImages() image1.width, image1.height=",image1.width,",",image1.height);
console.writeln("CcdParamsEngine.doImages() image2.width, image2.height=",image2.width,",",image2.height);
console.writeln("CcdParamsEngine.doImages() sumImage.width, sumImage.height=",sumImage.width,",",sumImage.height);
console.writeln("CcdParamsEngine.doImages() sumImage.width, sumImage.height=",diffImage.width,",",diffImage.height);
} // if debugging
var targetRect=this.computeTargetRect(image1,lengthFactor);
var cropped1=new Image();
cropped1.resetSelections();
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.doImages() assign(Image1)");
} // if debugging
cropped1.assign(image1);
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.doImages() cropTo()1");
} // if debugging
cropped1.cropTo(targetRect);
var cropped2=new Image();
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.doImages() assign(Image2)");
} // if debugging
cropped2.assign(image2);
cropped2.resetSelections();
cropped2.cropTo(targetRect);
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.doImages() cropTo()2");
} // if debugging
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.doImages() assign(cropped1)1");
} // if debugging
sumImage.assign(cropped1);
if ( DEBUGGING_MODE_ON ){
console.writeln("CcdParamsEngine.doImages() apply(Add)");
} // if debugging
...