Using ProcFunc and IP calls to write Image Processing Functions ProcFunc does all the work of opening image files, loading them into memory, and working with the information in the header to properly handle any processing that you want to do with the data. It also creates the user interface and gives the option to add your own widgets to the menu if desired. You may work with up to ten files,input and output combined, and can write programs that process a single image or combine data from different images/files. ProcFunc is the main program and there are just two subroutines that will be required from your program. But you have the flexiblility to have other routines called as well. I. IPAppSpecifics() This is the first required function in the application program. IPAppSpecifics is where you put all the IP calls that tell ProcFunc how you want it to work for you. Following is a list of the available calls. 1. IPSetMenuTitle(title); - set the title at the top of the menu char *title 2. IPSetMenuLoc(x,y); - set the location on the screen of the menu. int x,y: 3. IPAddInput(instream,label,require_flag,window_only,conv,file_open_handler,argu); - call this once for every input file required. - files are created in the menu in order of IPAddInput calls. Limitation: - up to 7 input channels can be created in each application int instream: the number you want to be used for the instream char *label : label for the input function button int require_flag : flags whether this file is required for the application to proceed or not. int window_only : flags whether the file must be a window or if it can also be a file. char *file_open_handler : names a function to be called after the file is opened if you want to do something special. int *argu : pointer to any arguments you want passed to your function. 4. IPAddOutput(istream,label,require_flag,window_only,conv,file_open_handler,argu); The current release only support one output channel. Multiple channels will be implemented in the next release. same parameters as IPAddInput 5. IPSetProcType(int itype); - by default 2D processing will be done, if you want 3D or 4D processing then call this routine with the appropriate flag. int itype - use defined constants TWO_D, THREE_D, FOUR_D 6. IPSetCustRoutine(func_op,func,argu); - this call lets you hook routines specific to your application into different parts of the processing. int func_op: describes the place in ProcFunc where your routine will be called. Use one of these constants: CUS_MENU - lets you add widgets to the menu by calling your routine half way though making the menu. INIT_PROC - calls your routine just before the processing begins in case you need to initialize anything PROC_FUNC - calls your 2d, 3d, or 4d processing routine AFTER_DO_IT - calls your routine after the processing so you can finish up anything you need to take care of at the end CUST_DOIT - if your processing is needs to be done differently then normal 2d, 3d or 4d processing you can control everything by having your custom doit called instead of going thru the regular processing routine. CLEAN_UP_PROC - calls your routine when you exit the program in case there is any graphics or something to clean up. INTERRUPT-calls your routine whenever the user interrupts processing CUST_DOIT- if none of the methods of processing work for your case you can skip the regular processing loop and call your own looping routine. NEW_REGION-calls your routine whenever a new region is selected CHANGE_MODE- calls your routine whenever user changes output mode char *func : function name int *argu : pointer to any arguments you want passed to the function 7. IPSetIncoreProc(); - this call sets the output array to just be the same as the input array. 8. IPEnableDoSec(); - this routine adds the option to the menu for the user to process the whole data range or just the current section. 9. IPSetDefOutPutMode(int mode) - you can set what the output mode will be by default modes are 0 byte 1 integer 2 float 3 complex_short 4 complex 10. IPSetDisChgHandler(which_file,func,argu); - if you want a routine to be called whenever there is a display change such a change section or zoom in a the selected window. int which_file : actually only works on the first input file use 1 char *func - the name of the function to call in event of display change int *argu - pointer to arguments to call for this function 11. IPSetNoAppend(); - setting this call means that the output from this process should not be appended to an existing file or window so that when the user uses an existing output, the option will only be to overwrite or cancel and the append option is disabled. 12. IPSetNoAutoIO(); - setting this call means that you are going to handle all of the io yourself and you don't want procfunc to do any memory allocations for data. II. The Second required subroutine is your processing function. You defined the name of it for ProcFunc by calling IPSetCUSTRoutine(PROC_FUNC,proc_func);. The processing function will be activated as following: If you set 2D Processing your proc_data will be called once for every section of data in the selected range. proc_func(int nxyz[3],float dmmm[3]) { } array nxyz holds the x y and z size of the data to be processed. the section passed is the size of nxyz[0] * nxyz[1] array dmmm is for processing routine to pass back the min max mean value of the processed data such that proper min/max info can be recored in each output file. If you set THREE_D, FOUR_D, or FOUR_D_WAVE, then it will call your proc_func routine once for each data volume, for each wave when there are multiple waves and times, or each time when there are multiple waves and times respectively. There are no parameters passed to the proc_data routine in these cases. III. These calls are extra info you may need if you are doing something more complicated than 2D processing. They can be called at any time from your program. IPGetFilename(istream,filename); - you may want the filename so you can ....... int istream : the istream you associated with the file in IPAddInput or IPAddOutput char *filename : pointer to string to hold filename IPPostInfo(string) - call this everytime you want to update the status window. char *string - the message to put in the status field IPGetRegionWidgets(Widget widgets[8]) - this routine returns to you the widget ids of the region input fields. where the eight widgets returned to you are. This is in case you need to disable them. 1. xy start/size field 2. z start end field 3. t start end field 4 - 8. wave toggles IPGetRegionInfo(int nxyzt[4][3],int iwave[5]); - routine returns to you the total region information for the data currently being processed. nxyzt[0][0] = xstart [0][1] = xend [0][2] = xinc always equal to 1 nxyzt[1][0-2] = ystart,yend,yinc yinc always 1 nxyzt[2][0-2] = zstart,zend,zinc nxyzt[3][0-2] = tstart,tend,tinc iwave[0-4] = set to zero or one for if the toggles are turned on IPSetDataPtr(int channel, float *array) - lets you set the output ptr in procfunc to an array you allocate in your routine. This would be used if say you needed output to be a different size than the input file was. float *IPGetDataPtr(int channel) - returns the ptr to the array of data corresponding to the io channel you request. IPGetCurZWT(int in_out_zwt[6]) - calling this routine inside the proc_data routine, returns the current input zwt section and current output zwt section as it loops through the data. int IPCheckInterrupt(); - returns true if user has hit the interrupt button if you need to handle something in your program if there is an interrupt, you can periodically make this call. IPSetFirstWaveMMM(float min, float max, float mean) - If you do 3D or 4D processing, you need to make this call after the first wave is processed to so that at the when IMWrHdr is called it will have these values. IPSetSclParam(int channel, float scale[4]); - Set the initial scaling of an image