# Copyright restrictions apply - see stsdas$copyright.stsdas # include # UNSTEP -- Combine data from several image groups into one group # # B.Simon 3-Sept-87 First Code procedure unstep() #-- char in_list[SZ_FNAME] # Input image name char out_list[SZ_FNAME] # Output image name char step_var[8] # Stepping factor keyword or vale bool mix # Way pixels are combined char in_file[SZ_FNAME] char out_image[SZ_LINE] int in_num, out_num, factor, ic pointer in_ptr, out_ptr pointer imi string wrongnum "Wrong number of groups for unstepping" string wrongdimen "Image must be one dimensional" bool tp_fetch(), clgetb() int ctoi(), imgeti() pointer tp_open(), immap() begin # Read the task parameters call clgstr ("inimage", in_list, SZ_LINE) call clgstr ("outimage", out_list, SZ_LINE) call clgstr ("stepvar", step_var, 8) mix = clgetb ("mix") # Expand the image template into a list of images, each with one # group. Check that the number of groups in the input image matches # the slicing factor. in_ptr = tp_open (in_list, 0, in_num) call imgcluster (in_list, in_file, SZ_FNAME) imi = immap (in_file, READ_ONLY, 0) ic = 1 if (ctoi (step_var, ic, factor) == 0) factor = imgeti (imi, step_var) if (mod (in_num, factor) != 0) { call tp_close (in_ptr) call error (1, wrongnum) } if (IM_NDIM(imi) != 1) { call tp_close (in_ptr) call error (1, wrongdimen) } call imunmap (imi) out_ptr = tp_open (out_list, in_num/factor, out_num) while (tp_fetch (out_ptr, out_image)) { if (mix) call shuffle (in_ptr, out_image, factor) else call append (in_ptr, out_image, factor) } # Close image lists and exit call tp_close(in_ptr) call tp_close(out_ptr) end