diff --git a/src/COREMOD_arith/CMakeLists.txt b/src/COREMOD_arith/CMakeLists.txt
index 5e1bd3e2..bc815cbf 100644
--- a/src/COREMOD_arith/CMakeLists.txt
+++ b/src/COREMOD_arith/CMakeLists.txt
@@ -8,7 +8,7 @@ message(" SRCNAME = ${SRCNAME} -> LIBNAME = ${LIBNAME}")
set(SOURCEFILES
${SRCNAME}.c
image_crop.c
- image_cropmask.c
+ image_crop2D.c
image_merge3D.c
image_norm.c
image_pixremap.c
@@ -37,6 +37,7 @@ set(SOURCEFILES
set(INCLUDEFILES
${SRCNAME}.h
image_crop.h
+ image_crop2D.h
image_cropmask.h
image_merge3D.h
image_norm.h
diff --git a/src/COREMOD_arith/COREMOD_arith.c b/src/COREMOD_arith/COREMOD_arith.c
index 097b1918..8df53494 100644
--- a/src/COREMOD_arith/COREMOD_arith.c
+++ b/src/COREMOD_arith/COREMOD_arith.c
@@ -50,7 +50,10 @@
//#include "COREMOD_arith/COREMOD_arith.h"
#include "image_crop.h"
-#include "image_cropmask.h"
+//#include "image_cropmask.h"
+#include "image_crop2D.h"
+
+
#include "image_dxdy.h"
#include "image_norm.h"
#include "image_slicenormalize.h"
@@ -102,7 +105,8 @@ static errno_t init_module_CLI()
CLIADDCMD_COREMOD_arith__image_normslice();
CLIADDCMD_COREMOD_arith__image_slicenormalize();
- CLIADDCMD_COREMODE_arith__cropmask();
+ //CLIADDCMD_COREMODE_arith__cropmask();
+ CLIADDCMD_COREMODE_arith__crop2D();
CLIADDCMD_COREMOD_arith__imset_1Dpixrange();
CLIADDCMD_COREMOD_arith__imset_2Dpix();
diff --git a/src/COREMOD_arith/image_crop2D.c b/src/COREMOD_arith/image_crop2D.c
new file mode 100644
index 00000000..632e73fa
--- /dev/null
+++ b/src/COREMOD_arith/image_crop2D.c
@@ -0,0 +1,196 @@
+/**
+ * @file image_crop2D.c
+ * @brief crop 2D function
+ *
+ *
+ */
+#include "CommandLineInterface/CLIcore.h"
+
+
+static char *cropinsname;
+long fpi_cropinsname;
+
+static char *outsname;
+long fpi_outsname;
+
+
+static uint32_t *cropxstart;
+long fpi_cropxstart;
+
+static uint32_t *cropxsize;
+long fpi_cropxsize;
+
+
+static uint32_t *cropystart;
+long fpi_cropystart;
+
+static uint32_t *cropysize;
+long fpi_cropysize;
+
+
+
+
+
+
+
+static CLICMDARGDEF farg[] =
+{
+ {
+ CLIARG_IMG,
+ ".insname",
+ "input stream name",
+ "inim",
+ CLIARG_VISIBLE_DEFAULT,
+ (void **) &cropinsname,
+ &fpi_cropinsname
+ },
+ {
+ CLIARG_STR,
+ ".outsname",
+ "output stream name",
+ "outim",
+ CLIARG_VISIBLE_DEFAULT,
+ (void **) &outsname,
+ &fpi_outsname
+ },
+ {
+ CLIARG_UINT32,
+ ".cropxstart",
+ "crop x coord start",
+ "30",
+ CLIARG_VISIBLE_DEFAULT,
+ (void **) &cropxstart,
+ &fpi_cropxstart
+ },
+ {
+ CLIARG_UINT32,
+ ".cropxsize",
+ "crop x coord size",
+ "32",
+ CLIARG_VISIBLE_DEFAULT,
+ (void **) &cropxsize,
+ &fpi_cropxsize
+ },
+ {
+ CLIARG_UINT32,
+ ".cropystart",
+ "crop y coord start",
+ "20",
+ CLIARG_VISIBLE_DEFAULT,
+ (void **) &cropystart,
+ &fpi_cropystart
+ },
+ {
+ CLIARG_UINT32,
+ ".cropysize",
+ "crop y coord size",
+ "32",
+ CLIARG_VISIBLE_DEFAULT,
+ (void **) &cropysize,
+ &fpi_cropysize
+ }
+};
+
+
+
+// Optional custom configuration setup.
+// Runs once at conf startup
+//
+static errno_t customCONFsetup()
+{
+ if(data.fpsptr != NULL)
+ {
+ data.fpsptr->parray[fpi_cropinsname].fpflag |=
+ FPFLAG_STREAM_RUN_REQUIRED | FPFLAG_CHECKSTREAM;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+// Optional custom configuration checks.
+// Runs at every configuration check loop iteration
+//
+static errno_t customCONFcheck()
+{
+
+ if(data.fpsptr != NULL)
+ {
+ }
+
+ return RETURN_SUCCESS;
+}
+
+static CLICMDDATA CLIcmddata =
+{
+ "crop2D", "crop 2D image", CLICMD_FIELDS_DEFAULTS
+};
+
+// detailed help
+static errno_t help_function()
+{
+ return RETURN_SUCCESS;
+}
+
+
+
+
+
+
+
+static errno_t compute_function()
+{
+ DEBUG_TRACE_FSTART();
+
+ // CONNECT TO INPUT STREAM
+ IMGID imgin = mkIMGID_from_name(cropinsname);
+ resolveIMGID(&imgin, ERRMODE_ABORT);
+
+ // CONNNECT TO OR CREATE OUTPUT STREAM
+ IMGID imgout = stream_connect_create_2Df32(outsname, *cropxsize, *cropysize);
+
+ INSERT_STD_PROCINFO_COMPUTEFUNC_INIT;
+
+
+
+ INSERT_STD_PROCINFO_COMPUTEFUNC_LOOPSTART
+ {
+
+ for(uint32_t jj = 0; jj < *cropysize; jj++)
+ {
+ uint64_t indjj = jj + (*cropystart);
+ indjj *= imgin.md->size[0];
+
+ memcpy( &imgout.im->array.F[ jj * (*cropxsize)],
+ &imgin.im->array.F[ indjj + (*cropxstart) ],
+ *cropxsize * SIZEOF_DATATYPE_FLOAT);
+
+ }
+ processinfo_update_output_stream(processinfo, imgout.ID);
+
+ }
+ INSERT_STD_PROCINFO_COMPUTEFUNC_END
+
+ DEBUG_TRACE_FEXIT();
+ return RETURN_SUCCESS;
+}
+
+
+
+
+
+INSERT_STD_FPSCLIfunctions
+
+
+
+
+// Register function in CLI
+errno_t
+CLIADDCMD_COREMODE_arith__crop2D()
+{
+
+ CLIcmddata.FPS_customCONFsetup = customCONFsetup;
+ CLIcmddata.FPS_customCONFcheck = customCONFcheck;
+ INSERT_STD_CLIREGISTERFUNC
+
+ return RETURN_SUCCESS;
+}
diff --git a/src/COREMOD_arith/image_crop2D.h b/src/COREMOD_arith/image_crop2D.h
new file mode 100644
index 00000000..101a67d3
--- /dev/null
+++ b/src/COREMOD_arith/image_crop2D.h
@@ -0,0 +1,6 @@
+#ifndef COREMOD_ARITH_CROP2D_H
+#define COREMOD_ARITH_CROP2D_H
+
+errno_t CLIADDCMD_COREMODE_arith__crop2D();
+
+#endif
diff --git a/src/COREMOD_arith/image_crop3D.c b/src/COREMOD_arith/image_crop3D.c
new file mode 100644
index 00000000..86d85f54
--- /dev/null
+++ b/src/COREMOD_arith/image_crop3D.c
@@ -0,0 +1,780 @@
+/**
+ * @file image_crop.c
+ * @brief crop functions
+ *
+ *
+ */
+
+#include "CommandLineInterface/CLIcore.h"
+
+#include "COREMOD_memory/COREMOD_memory.h"
+
+// ==========================================
+// Forward declaration(s)
+// ==========================================
+
+imageID arith_image_crop(const char *ID_name,
+ const char *ID_out,
+ long *start,
+ long *end,
+ long cropdim);
+
+imageID arith_image_extract2D(const char *in_name,
+ const char *out_name,
+ long size_x,
+ long size_y,
+ long xstart,
+ long ystart);
+
+imageID arith_image_extract3D(const char *in_name,
+ const char *out_name,
+ long size_x,
+ long size_y,
+ long size_z,
+ long xstart,
+ long ystart,
+ long zstart);
+
+// ==========================================
+// Command line interface wrapper function(s)
+// ==========================================
+
+static errno_t arith_image_extract2D__cli()
+{
+ if(0 + CLI_checkarg(1, CLIARG_IMG) + CLI_checkarg(2, CLIARG_STR_NOT_IMG) +
+ CLI_checkarg(3, CLIARG_INT64) + CLI_checkarg(4, CLIARG_INT64) +
+ CLI_checkarg(5, CLIARG_INT64) + CLI_checkarg(6, CLIARG_INT64) ==
+ 0)
+ {
+ arith_image_extract2D(data.cmdargtoken[1].val.string,
+ data.cmdargtoken[2].val.string,
+ data.cmdargtoken[3].val.numl,
+ data.cmdargtoken[4].val.numl,
+ data.cmdargtoken[5].val.numl,
+ data.cmdargtoken[6].val.numl);
+
+ return CLICMD_SUCCESS;
+ }
+ else
+ {
+ return CLICMD_INVALID_ARG;
+ }
+}
+
+static errno_t arith_image_extract3D__cli()
+{
+ if(0 + CLI_checkarg(1, CLIARG_IMG) + CLI_checkarg(2, CLIARG_STR_NOT_IMG) +
+ CLI_checkarg(3, CLIARG_INT64) + CLI_checkarg(4, CLIARG_INT64) +
+ CLI_checkarg(5, CLIARG_INT64) + CLI_checkarg(6, CLIARG_INT64) +
+ CLI_checkarg(7, CLIARG_INT64) + CLI_checkarg(8, CLIARG_INT64) ==
+ 0)
+ {
+ arith_image_extract3D(data.cmdargtoken[1].val.string,
+ data.cmdargtoken[2].val.string,
+ data.cmdargtoken[3].val.numl,
+ data.cmdargtoken[4].val.numl,
+ data.cmdargtoken[5].val.numl,
+ data.cmdargtoken[6].val.numl,
+ data.cmdargtoken[7].val.numl,
+ data.cmdargtoken[8].val.numl);
+
+ return CLICMD_SUCCESS;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+// ==========================================
+// Register CLI command(s)
+// ==========================================
+
+errno_t image_crop_addCLIcmd()
+{
+
+ RegisterCLIcommand(
+ "extractim",
+ __FILE__,
+ arith_image_extract2D__cli,
+ "crop 2D image",
+ "