PixelMath with ImageContainer

Alejandro Tombolini

PixInsight Ambassador
Hi,

I have a set of 300 images in a ImageContainer and I would need to apply a PixelMath process that make image1 - image2, image 2 - image3, image n - image n+1
Any help with the formula would be appreciated!  :)

Thank you
Alejandro.
 
Hi Alejandro!
Put in the Image Container
the files which you want to use and
put the expression:
image;&count;&extension;
into "Output template:"
this writes your files to the selected output directory as:
image_00001
image_00002

Yes it creates allso these files as views in your workspace but a
"Close All" removes them all.

In PixelMath put your formula and simply  click "Create new image"
and set the Image id to:            image

This is how it works for me.

Gerald
 
Hi Gerald!!,

oldwexi said:
In PixelMath put your formula and simply  click "Create new image"
and set the Image id to:            image
Gerald

Which would be the Pixelmath expresion?

I already have all the images in Image container named form image0001 to image0300. What I want to achieve is to subtract image0002 from image0001, then subtract image0003 from image0002, image0004 form image0003 and so on.

Alejandro.
 
Usually i use $T and do calculations with the actual image.

I have no idea how to access the last image for calculations with the actual image.
Will think about it but dont see a big chance.

Your request would need a little script which calls PixelMath with the formula and does the job
with actual image and previous image...

Sorry for havin no solution for your specific question.

Gerald
 
Hi Alejandro,

These tasks can be implemented very easily as scripts. What you are describing is beyond the scope of the PixelMath process.

Here is a small script (34 lines) that does exactly what you want:

Code:
#include <pjsr/ImageOp.jsh>
#include <pjsr/UndoFlag.jsh>

function SubtractSuccessiveImages( inputTemplate, outputDir )
{
   let inputFiles = searchDirectory( inputTemplate );
   inputFiles.sort();

   for ( let i = 0; i < inputFiles.length-1; ++i )
   {
      let thisWindow = ImageWindow.open( inputFiles[i] )[0];
      let nextWindow = ImageWindow.open( inputFiles[i+1] )[0];
      let thisView = thisWindow.mainView;
      let nextView = nextWindow.mainView;
      thisView.beginProcess( UndoFlag_NoSwapFile );
      thisView.image.apply( nextView.image, ImageOp_Sub );
      thisView.endProcess();

      let outputFilePath = outputDir + format( "/%03d-%03d.xisf", i+1, i+2 );
      if ( !thisWindow.saveAs( outputFilePath,
                               false/*queryOptions*/,
                               false/*allowMessages*/,
                               true/*strict*/,
                               false/*verifyOverwrite*/ ) )
      {
         console.criticalln( "*** Error: Failure to write output image: ", outputFilePath );
         break;
      }

      thisWindow.forceClose();
   }
}

SubtractSuccessiveImages( "/Users/juan/test/*.xisf", "/Users/juan/test/output" );

The script performs subtractions between successive pairs of images, which it finds on a specified input directory. The results are written to a specified output directory. The script assumes that the order of images corresponds to the list of image file names sorted alphabetically in ascending order. I think the script is quite self-describing; let me know if you need further help to understand how it works.

PixInsight is a scriptable environment precisely to solve this kind of problems.


 
Back
Top