Skip to content

Commit

Permalink
crop2D
Browse files Browse the repository at this point in the history
  • Loading branch information
oguyon committed Aug 15, 2024
1 parent 1000069 commit 22840e4
Show file tree
Hide file tree
Showing 8 changed files with 1,035 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/COREMOD_arith/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/COREMOD_arith/COREMOD_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
196 changes: 196 additions & 0 deletions src/COREMOD_arith/image_crop2D.c
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 6 additions & 0 deletions src/COREMOD_arith/image_crop2D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef COREMOD_ARITH_CROP2D_H
#define COREMOD_ARITH_CROP2D_H

errno_t CLIADDCMD_COREMODE_arith__crop2D();

#endif
Loading

0 comments on commit 22840e4

Please sign in to comment.