/* * Khoros: $Id$ */ #if !defined(__lint) && !defined(__CODECENTER__) static char rcsid[] = "Khoros: $Id$"; #endif /* * Copyright (C) 1993 - 1997, Khoral Research, Inc., ("KRI"). * All rights reserved. See $BOOTSTRAP/repos/license/License or run klicense. */ /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<< >>>> >>>> Main program for mylaplacianofgaussian >>>> >>>> Private: >>>> main >>>> >>>> Static: >>>> Public: >>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<< */ #include "mylaplacianofgaussian.h" clui_info_struct *clui_info = NULL; /*----------------------------------------------------------- | | Routine Name: main() - Laplacian of Gaussian | | Purpose: main program for mylaplacianofgaussian | | Input: | int clui_info->size_int; {integer} | int clui_info->size_flag; {TRUE if -size specified} | | float clui_info->sigma_float; {float} | int clui_info->sigma_flag; {TRUE if -sigma specified} | | char *clui_info->o_file; {Resulting output data object} | int clui_info->o_flag; {TRUE if -o specified} | | Output: | Returns: | | Written By: | Date: July 1, 1997 | Modifications: | ------------------------------------------------------------*/ int main( int argc, char **argv) { /* -main_variable_list */ char *lib = "mylaplacianofgaussian_obj"; char *rtn = "main"; kobject out_object = NULL; double *res_plane; int w, h, d, t, e; int cw, ch, ct, pos, cx, cy, x, y; /* x, y segédváltozó, cx, cy a kép közepe lesz */ double sigma2; /* új változó: a szigma négyzete */ double sigma4; /* uj változó a 4-ik hatványhoz */ double k; /* ebbe fogjuk letárolni a konstans értéket */ /* -main_variable_list_end */ khoros_init(argc, argv, "PROBA", PRODUCT_RELEASE_DATE, PRODUCT_RELEASE_NAME, PRODUCT_RELEASE_VERSION, PRODUCT_RELEASE_MAJOR, PRODUCT_RELEASE_MINOR, "$PROBA/objects/kroutine/mylaplacianofgaussian"); kexit_handler(mylaplacianofgaussian_free_args, NULL); /* -main_get_args_call */ kclui_init("PROBA", "mylaplacianofgaussian", KGEN_KROUTINE, &clui_uis_spec, mylaplacianofgaussian_usage_additions, mylaplacianofgaussian_get_args, mylaplacianofgaussian_free_args); /* -main_get_args_call_end */ /* -main_before_lib_call */ /* nincs input kép, csak az output képet kell megnyitni */ if ((out_object = kpds_open_output_object(clui_info->o_file)) == KOBJECT_INVALID) { kerror(lib, rtn, "Can not open output object %s.\n", clui_info->o_file); kexit(KEXIT_FAILURE); } /* létre kell hozni a Value szegmenst */ kpds_create_value( out_object ); kpds_set_attribute(out_object, KPDS_VALUE_DATA_TYPE, KDOUBLE); /* az adattípus KDOUBLE lesz */ /* beállítjuk a kép méretét */ w = clui_info->size_int; h = w; d = 1; t = 1; e = 1; sigma2 = clui_info->sigma_float * clui_info->sigma_float; sigma4 = sigma2 * sigma2; kpds_set_attribute( out_object, KPDS_VALUE_SIZE, w, h, d, t, e ); res_plane = (double* ) kmalloc ( w * h * sizeof(double) ); if ( !res_plane ) { kerror(lib, rtn, "Could not allocate memory for the image\n"); kexit(KEXIT_FAILURE); } /* -main_before_lib_call_end */ /* -main_library_call */ /* kiszamolom a kep kozepet */ cx = w / 2; cy = h / 2; kmemset( res_plane, 0.0, w * h* sizeof(double) ); /* kiszamolom a fuggvenyertekeket ugy, hogy a kep kozepe legyen az origo (valojaban ez nem a kep origoja!!!)*/ for ( ch = 0, y = -cy; ch < h; ch++, y++ ) { for ( cw = 0, x = -cx; cw < w; cw++, x++ ) { pos = ch * w + cw; res_plane[pos] = (( x * x + y * y - 2.0 * sigma2 ) / ( sigma4 )) * exp( -( x * x + y * y ) / ( 2.0 * sigma2) ); } } kpds_set_attribute( out_object, KPDS_VALUE_POSITION, 0,0,0,0,0 ); kpds_put_data( out_object, KPDS_VALUE_PLANE, (kaddr) res_plane ); /* -main_library_call_end */ /* -main_after_lib_call */ if (!kpds_set_attribute(out_object, KPDS_HISTORY, kpds_history_string())) { kerror(lib,rtn,"Unable to set history on the destination object"); kexit(KEXIT_FAILURE); } kpds_close_object( out_object ); kfree( res_plane ); /* -main_after_lib_call_end */ kexit(KEXIT_SUCCESS); } /*----------------------------------------------------------- | | Routine Name: mylaplacianofgaussian_usage_additions | | Purpose: Prints usage additions in mylaplacianofgaussian_usage routine | | Input: None | | Output: None | Written By: ghostwriter -oname mylaplacianofgaussian | Date: July 1, 1997 | Modifications: | ------------------------------------------------------------*/ void mylaplacianofgaussian_usage_additions(void) { kfprintf(kstderr, "\tLaplacian of Gaussian\n"); /* -usage_additions */ /* -usage_additions_end */ } /*----------------------------------------------------------- | | Routine Name: mylaplacianofgaussian_free_args | | Purpose: Frees CLUI struct allocated in mylaplacianofgaussian_get_args() | | Input: None | | Output: None | Written By: ghostwriter -oname mylaplacianofgaussian | Date: July 1, 1997 | Modifications: | ------------------------------------------------------------*/ /* ARGSUSED */ void mylaplacianofgaussian_free_args( kexit_status status, kaddr client_data) { /* do the wild and free thing */ if (clui_info != NULL) { kfree_and_NULL(clui_info->o_file); kfree_and_NULL(clui_info); } /* -free_handler_additions */ /* -free_handler_additions_end */ }