[Swift-commit] r3428 - SwiftApps/Montage
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Tue Jul 6 16:54:12 CDT 2010
Author: jonmon
Date: 2010-07-06 16:54:12 -0500 (Tue, 06 Jul 2010)
New Revision: 3428
Added:
SwiftApps/Montage/Swift_Montage_Apps.swift
SwiftApps/Montage/Swift_Montage_Batch.swift
SwiftApps/Montage/Swift_Montage_Types.swift
Modified:
SwiftApps/Montage/montage.swift
Log:
o SwiftApps/Montage/Swift_Montage_Batch.swift
o SwiftApps/Montage/Swift_Montage_Apps.swift
o SwiftApps/Montage/Swift_Montage_Types.swift
-- Moved Batch functions, app functions, and declared types into appropriate files
o Montage/montage.swift
-- Now only import above files into script file. This change was for organization.
Added: SwiftApps/Montage/Swift_Montage_Apps.swift
===================================================================
--- SwiftApps/Montage/Swift_Montage_Apps.swift (rev 0)
+++ SwiftApps/Montage/Swift_Montage_Apps.swift 2010-07-06 21:54:12 UTC (rev 3428)
@@ -0,0 +1,135 @@
+/*! \file Swift_Montage_Apps.swift
+ \brief File containing Swift wrappers to basic Montage functions
+
+ Each app function is a wrapper to a scalar Montage function.
+ Using the word scalar becuase each function takes a single image to
+ work on unlike the Swift batch functions.
+*/
+
+
+/*! \fn app Image mAdd( Image imgs[], Table img_tbl, MosaicData hdr )
+ \brief Adds all images in imgs[] into one image file based off the information in img_tbl and hdr.
+
+ \param imgs[] List of images to be added into one image. All images but reside in same directory.
+ \param img_tbl Table containing information about images being added
+ \param hdr MosaicData file containing information about how mosaic will look.
+ \return mos Image file containing data about mosaic.
+*/
+( Image mos ) mAdd( Image imgs[], Table img_tbl, MosaicData hdr )
+{
+ app
+ {
+ mAdd "-p" @dirname( imgs[0] ) "-n" @img_tbl @hdr @mos;
+ }
+}
+
+
+/*! \fn app Image mBackground( Image img, Table img_tbl, Table corr_tbl )
+ \brief Generates a corrected image from imgs and the information from corr_tbl
+
+ \param img Image to be corrected
+ \param img_tbl Table containing information about images being added
+ \param corr_tbl Correction table containing correction coefficients to be applied
+ \return mos bg_img corrected image
+*/
+( Image bg_img ) mBackground( Image img, Table img_tbl, Table corr_tbl )
+{
+ app
+ {
+ mBackground "-n" @img @bg_img @img_tbl @corr_tbl;
+ }
+}
+
+
+/*! \fn app Table mBgModel( Table img_tbl, Table fits_tbl )
+ \brief Generates the corrected image table from the coefficeints data from fits_tbl and data from the projected image table
+
+ \param img_tbl Table containing information about the projected images.
+ \param fits_tbl Table containing information about how to correct an image
+ \return corr_tbl Correction table containing correction coefficients to be applied
+*/
+( Table corr_tbl ) mBgModel( Table img_tbl, Table fits_tbl )
+{
+ app
+ {
+ mBgModel @img_tbl @fits_tbl @corr_tbl;
+ }
+}
+
+
+/*! \fn app Image mDiff( Image proj_img_1, Image proj_img_2, MosaicData hdr )
+ \brief Calculates the difference image from the two projected images and the header file.
+
+ \param proj_img_1 The first image to calculate how much is overlapped
+ \param proj_img_2 The second image to calculate how much is overlapped
+ \param hdr MosaicData file that tells how the mosaic is set up
+ \return diff_img Difference image that contains overlapped information
+*/
+( Image diff_img ) mDiff( Image proj_img_1, Image proj_img_2, MosaicData hdr )
+{
+ app
+ {
+ mDiff "-n" @proj_img_1 @proj_img_2 @diff_img @hdr;
+ }
+}
+
+
+/*! \fn app Table mImgtbl( Image imgs[] )
+ \brief Take a list of of images and create a table out of them. All images in the list must be located in the same directory.
+
+ \param imgs[] List of files to create an table out of.
+ \return img_tbl Table of information of the list of images.
+*/
+( Table img_tbl ) mImgtbl( Image imgs[] )
+{
+ app
+ {
+ mImgtbl @dirname( imgs[0] ) @img_tbl;
+ }
+}
+
+
+/*! \fn app JPEG mJPEG( Image mos_img )
+ \brief Creates a viewable jpeg image from the mosaic data image
+
+ \param mos_img Image file to create a jpeg out of.
+ \return mos_img_jpg Jpeg picture.
+*/
+( JPEG mos_img_jpg ) mJPEG( Image mos_img )
+{
+ app
+ {
+ mJPEG "-gray" @mos_img "20%" "99.98%" "loglog" "-out" @mos_img_jpg;
+ }
+}
+
+
+/*! \fn app Table mOverlaps( Table img_tbl )
+ \brief Calculates which images overlaps each other and creates a table out of.
+
+ \param img_tbl Table of projected images.
+ \return diff_tbl Table of which overlapped images
+*/
+( Table diff_tbl ) mOverlaps( Table img_tbl )
+{
+ app
+ {
+ mOverlaps @img_tbl @diff_tbl;
+ }
+}
+
+
+/*! \fn app Image mProjectPP( Image raw_img, MosaicData hdr )
+ \brief Projects an image based off of the header file.
+
+ \param raw_img Raw image to project.
+ \param hdr MosaicData file telling how the mosaic will be set up in the end.
+ \return proj_img Projected image.
+*/
+( Image proj_img ) mProjectPP( Image raw_img, MosaicData hdr )
+{
+ app
+ {
+ mProjectPP "-X" @raw_img @proj_img @hdr;
+ }
+}
Added: SwiftApps/Montage/Swift_Montage_Batch.swift
===================================================================
--- SwiftApps/Montage/Swift_Montage_Batch.swift (rev 0)
+++ SwiftApps/Montage/Swift_Montage_Batch.swift 2010-07-06 21:54:12 UTC (rev 3428)
@@ -0,0 +1,103 @@
+/*! \file Swift_Montage_Batch.swift
+ \brief File containing Batch functions for the Swift Montage wrappers
+
+ Each batch function allows basic Montage functions to be called on a list of
+ images.
+*/
+
+
+/*! \fn Image mBgBatch( Image bg_imgs[], Table img_tbl, Table corr_tbl )
+ \brief Runs the mBackground wrapper on a list of images in parallel.
+
+ \param bg_imgs[] The list of images to run the mBackground wrapper on.
+ \param img_tbl Table containing information on original images.
+ \param corr_tbl Table containing correction coefficients to be applied to the images.
+ \return corr_imgs[] List of the corrected images to be added to create image mosaic.
+*/
+( Image corr_imgs[] ) mBgBatch( Image bg_imgs[], Table img_tbl, Table corr_tbl )
+{
+
+ /* ImageStruct img_struct_tbl[] <>; */
+ /* CorrectStruct correct_stuct_tbl[] <>; */
+ /* Image proj_img; */
+ /* Image corr_img; */
+ /* int A; */
+ /* int B; */
+ /* int C; */
+
+ /* foreach img_tbl_entry, i in img_struct_tbl */
+ /* { */
+ /* foreach correct_tbl_entry in correct_struct_tbl */
+ /* { */
+ /* if( img_tbl_entry.cntr == correct_tbl_entry.id ) */
+ /* { */
+ /* img <single_file_mapper; file = @strcat( @dirname( bg_imgs[0] ), @img_tbl_entry.fname ); */
+ /* corr_img <regexp_mapper; source = @img, match = ".*\\\\/(.*)", transform = "corr_dir/corr_\\1">; */
+
+ /* corr_img = mBackground( img, A, B, C ); */
+
+ /* corr_imgs[ i ] = corr_img; */
+ /* } */
+ /* } */
+ /* } */
+}
+
+
+/*! \fn Image mDiffBatch( Table diff_tbl, MosaicData hdr )
+ \brief Runs the mDiff wrapper on a list of images in parallel.
+
+ \param diff_tbl Table containing a list of images that overlap and must calculate by how much they overlap.
+ \param hdr File containing information on how the final mosaic will be set up.
+ \return diff_imgs[] List of the difference images that must have correction coefficients calculated.
+*/
+( Image diff_imgs[] ) mDiffBatch( Table diff_tbl, MosaicData hdr )
+{
+ DiffStruct diffs[] <csv_mapper; file = diff_tbl, skip = 1, hdelim="| ">;
+
+ foreach d_entry, i in diffs
+ {
+ Image proj_1 <single_file_mapper; file = @strcat( "proj_dir/", @d_entry.plus )>;
+ Image proj_2 <single_file_mapper; file = @strcat( "proj_dir/", @d_entry.minus )>;
+
+ Image diff_img <single_file_mapper; file = @strcat( "diff_dir/", @d_entry.diff )>;
+ diff_img = mDiff( proj_1, proj_2, hdr );
+
+ diff_imgs[ i ] = diff_img;
+ }
+}
+
+
+/*! \fn app Table mFitBatch( Table diff_tbl, Image diff_imgs[] )
+ \brief Generates a corrected image from imgs and the information from corr_tbl
+
+ \param diff_tbl
+ \param diff_imgs
+ \return fits_tbl
+*/
+( Table fits_tbl ) mFitBatch( Table diff_tbl, Image diff_imgs[] )
+{
+ app
+ {
+ mFitExec @diff_tbl @fits_tbl @dirname( diff_imgs[0] );
+ }
+}
+
+
+/*! \fn Image mProjectPPBatch( Image raw_imgs[], MosaicData hdr )
+ \brief Projects the raw images from raw_imgs to a new plane that was declared in hdr.
+
+ \param raw_imgs[] List of raw images that need to be projected to new plane.
+ \param hdr File containing information on how the final mosaic will be set up.
+ \return proj_imgs[] List of newly reprojected images.
+*/
+( Image proj_imgs[] ) mProjectPPBatch( Image raw_imgs[], MosaicData hdr )
+{
+ foreach img, i in raw_imgs
+ {
+ Image proj_img <regexp_mapper; source = @img, match = ".*\\/(.*)", transform = "proj_dir/proj_\\1">;
+
+ proj_img = mProjectPP( img, hdr );
+
+ proj_imgs[ i ] = proj_img;
+ }
+}
Added: SwiftApps/Montage/Swift_Montage_Types.swift
===================================================================
--- SwiftApps/Montage/Swift_Montage_Types.swift (rev 0)
+++ SwiftApps/Montage/Swift_Montage_Types.swift 2010-07-06 21:54:12 UTC (rev 3428)
@@ -0,0 +1,59 @@
+/*! \file Swift_Montage_Types.swift
+ \brief File containing declared Swift types for the Swift Montage wrappers
+*/
+
+/*! \typdef type Image
+ \brief Declared Image Swift type.
+*/
+type Image;
+
+
+/*! \typdef type MosaicData
+ \brief Declared MosaicData Swift type.
+*/
+type MosaicData;
+
+
+/*! \typdef type Table
+ \brief Declared Table Swift type.
+*/
+type Table;
+
+
+/*! \typdef type JPEG
+ \brief Declared JPEG Swift type.
+*/
+type JPEG;
+
+
+/*! \struct CorrectStruct
+ \brief Struct to hold data found in the table that is generated from the mBgModel wrapper.
+*/
+type CorrectStruct
+{
+ int id; /*!< The id referencing which image this entry belongs to */
+};
+
+
+/*! \struct DiffStruct
+ \brief Stuct to hold data found in the table that is generated from the mOverlaps wrapper.
+
+ \var int cntr1 The id referencing the first image in the difference table.
+*/
+type DiffStruct
+{
+ int cntr1; /*!< The id referencing the first image in the difference table. */
+ int cntr2; /*!< The id referencing the second image in the difference table. */
+ Image plus; /*!< The name of the image referenced by the id number cntr1. */
+ Image minus; /*!< The name of the image referenced by the id number cntr2. */
+ Image diff; /*!< The name of the difference image that was created by plus and minus. */
+};
+
+
+/*! \struct ImageStruct
+ \brief Struct to hold data found in the table that is generated from the mImgtbl wrapper.
+*/
+type ImageStruct
+{
+ int cntr; /*!< The id referencing which image this entry belongs to */
+};
Modified: SwiftApps/Montage/montage.swift
===================================================================
--- SwiftApps/Montage/montage.swift 2010-07-06 08:22:26 UTC (rev 3427)
+++ SwiftApps/Montage/montage.swift 2010-07-06 21:54:12 UTC (rev 3428)
@@ -1,137 +1,8 @@
-type Image;
-type Header;
-type Table;
-type JPEG;
-type TxtFile;
-type DiffStruct
-{
- int cntr1;
- int cntr2;
- Image plus;
- Image minus;
- Image diff;
-}
+import Swift_Montage_Types;
+import Swift_Montage_Apps;
+import Swift_Montage_Batch;
-( Image mos ) mAdd ( Image imgs[], Table img_tbl, Header hdr )
-{
- app
- {
-// mAddDirec @(imgs[0]) @img_tbl @hdr @mos;
- mAdd "-p" @dirname( imgs[0] ) "-n" @img_tbl @hdr @mos;
- }
-}
-
-( Image bg_img ) mBackground ( Image img, Table img_tbl, Table corr_tbl )
-{
- app
- {
- mBackground "-n" @img @bg_img @img_tbl @corr_tbl;
- }
-}
-
-/* ( Image corr_imgs[] ) mBgBatch ( Image bg_imgs[], Table img_tbl, Table corr_tbl ) */
-/* { */
-/* foreach img, i in bg_imgs */
-/* { */
-/* Image corr_img <regexp_mapper; source = @img, match = ".*\\\/(.*)", transform = "corr_dir/corr_\\1">; */
-
-/* corr_img = mBackground( img, img_tbl, corr_tbl ); */
-
-/* corr_imgs[ i ] = corr_img; */
-/* } */
-/* } */
-
-/* ( Image corr_imgs[] ) mBgBatch ( Table img_tbl, Table corr_tbl ) */
-mBgBatch ( Table img_tbl, Table corr_tbl )
-{
- app
- {
- mBgExec "-p" "proj_dir" "-n" @img_tbl @corr_tbl "corr_dir";
- }
-}
-
-( Table corr_tbl ) mBgModel ( Table proj_tbl, Table fits_tbl )
-{
- app
- {
- mBgModel @proj_tbl @fits_tbl @corr_tbl;
- }
-}
-
-( Image diff_img ) mDiff ( Image proj_img_1, Image proj_img_2, Header hdr )
-{
- app
- {
- mDiff "-n" @proj_img_1 @proj_img_2 @diff_img @hdr;
- }
-}
-
-( Image diff_imgs[] ) mDiffBatch ( Table diff_tbl, Header hdr )
-{
- DiffStruct diffs[] <csv_mapper; file = diff_tbl, skip = 1, hdelim="| ">;
-
- foreach d_entry, i in diffs
- {
- Image proj_1 <single_file_mapper; file = @strcat( "proj_dir/", @d_entry.plus )>;
- Image proj_2 <single_file_mapper; file = @strcat( "proj_dir/", @d_entry.minus )>;
-
- Image diff_img <single_file_mapper; file = @strcat( "diff_dir/", @d_entry.diff )>;
- diff_img = mDiff( proj_1, proj_2, hdr );
-
- diff_imgs[ i ] = diff_img;
- }
-}
-
-( Table fits_tbl ) mFitBatch ( Table diff_tbl, Image diff_imgs[] )
-{
- app
- {
- mFitExec @diff_tbl @fits_tbl @dirname( diff_imgs[0] );
- }
-}
-
-( Table img_tbl ) mImgtbl ( Image imgs[] )
-{
- app
- {
- mImgtbl @dirname( imgs[0] ) @img_tbl;
- }
-}
-
-( JPEG mos_img_jpg ) mJPEG ( Image mos_img )
-{
- app
- {
- mJPEG "-gray" @mos_img "20%" "99.98%" "loglog" "-out" @mos_img_jpg;
- }
-}
-
-app ( Table diff_tbl ) mOverlaps ( Table img_tbl )
-{
- mOverlaps @img_tbl @diff_tbl;
-}
-
-( Image proj_img ) mProjectPP ( Image raw_img, Header hdr )
-{
- app
- {
- mProjectPP "-X" @raw_img @proj_img @hdr;
- }
-}
-
-( Image proj_imgs[] ) mProjectPPBatch ( Image raw_imgs[], Header hdr )
-{
- foreach img, i in raw_imgs
- {
- Image proj_img <regexp_mapper; source = @img, match = ".*\\/(.*)", transform = "proj_dir/proj_\\1">;
-
- proj_img = mProjectPP( img, hdr );
-
- proj_imgs[ i ] = proj_img;
- }
-}
-
-Header template <"template.hdr">;
+MosaicData template <"template.hdr">;
Table images_tbl <"images.tbl">;
Table difference_tbl <"diffs.tbl">;
Table fits_images_tbl <"fits.tbl">;
@@ -156,7 +27,7 @@
// Up to here the scripts work.
-/* corrected_images = mBgBatch( images_tbl, corrections_tbl ); */
+//corrected_images = mBgBatch( images_tbl, corrections_tbl );
/* mBgBatch( images_tbl, corrections_tbl ); */
/* corrected_mos = mAdd( corrected_images, images_tbl, template ); */
/* corrected_jpg_img = mJPEG( corrected_mos ); */
More information about the Swift-commit
mailing list