/** * Find the background of a tif stack. * Output : integer * Input : stack file or bundle file. */ void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { if (nrhs != 1) mexErrMsgTxt("The function takes 1 argument."); if ( !mxIsChar(prhs[0]) ) mexErrMsgTxt("The argument must be a string"); char *filePath = mxArrayToString(prhs[0]); Stack *stack = NULL; if( strlen(filePath)>4 ) { if( Is_Tiff(filePath) ) /* Read file */ stack = Read_Stack(filePath); else if ( Is_Fbdf(filePath) ) { /* Read directory */ File_Bundle fb; initfb(&fb); if( Load_Fbdf(filePath,&fb) ) stack = Read_Stack_Planes(&fb); freefb(&fb); } else mexErrMsgTxt("Unrecongnized file format."); } else { mexErrMsgTxt("Unrecongnized file format."); } if( stack==NULL ) mexErrMsgTxt("Unable to load the stack."); if( stack->kind==GREY || stack->kind==GREY16 ) { int *hist = Stack_Hist(stack); int hist_size = hist[0] + 2; plhs[0] = mxCreateNumericMatrix(hist_size,1,mxINT32_CLASS,mxREAL); int i; int32_t *hist_pointer = (int32_t *) mxGetPr(plhs[0]); for(i = 0; i < hist_size; i++) hist_pointer[i] = hist[i]; free(hist); Kill_Stack(stack); } else { Kill_Stack(stack); mexErrMsgTxt("Unsupported image format."); } }
/** * Find the background of a tif stack. * Output : integer * Input : stack file or bundle file. */ void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { if (nrhs < 1 || nrhs > 3) mexErrMsgTxt("The function takes 1~3 arguments."); if ( !mxIsChar(prhs[0]) ) mexErrMsgTxt("The argument must be a string"); if (nrhs == 2) { if ( !tz_mxIsDoubleScalar(prhs[1]) ) mexErrMsgTxt("The second argument must be a doulbe scalar"); } if (nrhs == 3) { if ( !tz_mxIsDoubleScalar(prhs[2]) ) mexErrMsgTxt("The third argument must be a doulbe scalar"); } char *filePath = mxArrayToString(prhs[0]); Stack *stack = NULL; if( strlen(filePath)>4 ) { if( Is_Tiff(filePath) ) /* Read file */ stack = Read_Stack(filePath); else if ( Is_Fbdf(filePath) ) { /* Read directory */ File_Bundle fb; initfb(&fb); if( Load_Fbdf(filePath,&fb) ) stack = Read_Stack_Planes(&fb); freefb(&fb); } else mexErrMsgTxt("Unrecongnized file format."); } else { mexErrMsgTxt("Unrecongnized file format."); } if( stack==NULL ) mexErrMsgTxt("Unable to load the stack."); int *hist,com; int low,high; if( stack->kind==GREY || stack->kind==GREY16 ) { hist = Stack_Hist(stack); if (nrhs == 1) { low = hist[1]; high = hist[0]+hist[1]-1; } else if (nrhs == 2) { low = (int) (*mxGetPr(prhs[1])); high = hist[0]+hist[1]-1; } else { low = (int) (*mxGetPr(prhs[1])); high = (int) (*mxGetPr(prhs[2])); } printf("Pick threshold between %d and %d\n", low, high); com = Hist_Most_Common(hist,low,high); free(hist); Kill_Stack(stack); } else { Kill_Stack(stack); mexErrMsgTxt("Unsupported image format."); } uint8 *thre; uint16 *thre16; switch(stack->kind) { case GREY: plhs[0] = mxCreateNumericMatrix(1,1,mxUINT8_CLASS,mxREAL); thre = (uint8 *) mxGetPr(plhs[0]); *thre = com; break; case GREY16: plhs[0] = mxCreateNumericMatrix(1,1,mxUINT16_CLASS,mxREAL); thre16 = (uint16 *) mxGetPr(plhs[0]); *thre16 = com; break; defaut: Kill_Stack(stack); mexErrMsgTxt("Unsupported image format."); } }
int main(int argc, char *argv[]) { gtk_init(&argc, &argv); GtkBuilder *builder = gtk_builder_new(); AuthManager *authManager = g_slice_new(AuthManager); GError *error = NULL; if (!gtk_builder_add_from_file(builder, "authmanager.glade", &error)) { g_print( "Error occurred while loading UI description from file (authmanager.glade)!\n"); g_print("Message: %s\n", error->message); g_free(error); g_slice_free(AuthManager, authManager); return (1); } authManager->window = GTK_WIDGET( gtk_builder_get_object(builder, "mainwindow")); authManager->key_store = GTK_LIST_STORE( gtk_builder_get_object(builder, "KeyStore")); authManager->key_view = GTK_TREE_VIEW( gtk_builder_get_object(builder, "KeyView")); authManager->errordialog_nodir = GTK_WIDGET( gtk_builder_get_object(builder, "errordialog_nodir")); authManager->enabled_renderer = GTK_CELL_RENDERER( gtk_builder_get_object(builder, "cellrenderertoggle_enabled")); authManager->info_renderer = GTK_CELL_RENDERER( gtk_builder_get_object(builder, "cellrendererpixbuf_info")); authManager->edit_renderer = GTK_CELL_RENDERER( gtk_builder_get_object(builder, "cellrendererpixbuf_edit")); authManager->delete_renderer = GTK_CELL_RENDERER( gtk_builder_get_object(builder, "cellrendererpixbuf_delete")); authManager->newdialog.window = GTK_WIDGET( gtk_builder_get_object(builder, "newdialog_window")); authManager->newdialog.entry_authname = GTK_ENTRY( gtk_builder_get_object(builder, "newdialog_entry_authname")); authManager->newdialog.entry_privkey = GTK_ENTRY( gtk_builder_get_object(builder, "newdialog_entry_privkey")); authManager->newdialog.entry_domain = GTK_ENTRY( gtk_builder_get_object(builder, "newdialog_entry_domain")); authManager->editdialog.window = GTK_WIDGET( gtk_builder_get_object(builder, "editdialog_window")); authManager->editdialog.entry_authname = GTK_ENTRY( gtk_builder_get_object(builder, "editdialog_entry_authname")); authManager->editdialog.entry_privkey = GTK_ENTRY( gtk_builder_get_object(builder, "editdialog_entry_privkey")); authManager->editdialog.entry_domain = GTK_ENTRY( gtk_builder_get_object(builder, "editdialog_entry_domain")); authManager->infodialog.window = GTK_WIDGET( gtk_builder_get_object(builder, "infodialog_window")); authManager->infodialog.label_authname = GTK_LABEL( gtk_builder_get_object(builder, "infodialog_info_authname")); authManager->infodialog.label_privkey = GTK_LABEL( gtk_builder_get_object(builder, "infodialog_info_privkey")); authManager->infodialog.label_pubkey = GTK_LABEL( gtk_builder_get_object(builder, "infodialog_info_pubkey")); authManager->infodialog.label_domain = GTK_LABEL( gtk_builder_get_object(builder, "infodialog_info_domain")); authManager->infodialog.label_location = GTK_LABEL( gtk_builder_get_object(builder, "infodialog_info_location")); gtk_builder_connect_signals(builder, authManager); g_object_unref(G_OBJECT(builder)); gtk_widget_show(authManager->window); GTK_CELL_RENDERER_TOGGLE(authManager->enabled_renderer)->activatable = true; GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); authManager->info_icon_pixbuf = get_stock_icon(icon_theme, "Icons"FS_DELIM"200px-Gnome-dialog-information.png"); authManager->edit_icon_pixbuf = get_stock_icon(icon_theme, "Icons"FS_DELIM"200px-Gnome-accessories-text-editor.png"); authManager->delete_icon_pixbuf = get_stock_icon(icon_theme, "Icons"FS_DELIM"200px-Gnome-edit-delete.png"); if (!authManager->info_icon_pixbuf || !authManager->edit_icon_pixbuf || !authManager->delete_icon_pixbuf) { if (authManager->info_icon_pixbuf) g_object_unref(authManager->info_icon_pixbuf); if (authManager->edit_icon_pixbuf) g_object_unref(authManager->edit_icon_pixbuf); if (authManager->delete_icon_pixbuf) g_object_unref(authManager->delete_icon_pixbuf); g_slice_free(AuthManager, authManager); return (1); } if (!load_auth_information(authManager)) { gtk_dialog_run(GTK_DIALOG(authManager->errordialog_nodir)); } else { gtk_main(); } gtk_list_store_clear(authManager->key_store); freefb(&authManager->auth_cfg_buffer); freefb(&authManager->autoexec_cfg_buffer); if (authManager->auth_cfg_file) g_object_unref(authManager->auth_cfg_file); if (authManager->autoexec_cfg_file) g_object_unref(authManager->autoexec_cfg_file); if (authManager->auth_cfg_monitor) g_object_unref(authManager->auth_cfg_monitor); if (authManager->autoexec_cfg_monitor) g_object_unref(authManager->autoexec_cfg_monitor); if (authManager->sauer_home) free(authManager->sauer_home); if (authManager->info_icon_pixbuf) g_object_unref(authManager->info_icon_pixbuf); if (authManager->edit_icon_pixbuf) g_object_unref(authManager->edit_icon_pixbuf); if (authManager->delete_icon_pixbuf) g_object_unref(authManager->delete_icon_pixbuf); g_slice_free(AuthManager, authManager); return 0; }