include "register.h" procedure expxvw (input, dim, wndo, rcentr, rwidth,x, y, status) # expxvw -- Extracts locations and values of good pixels from data window # # Description: # ------------ # This subroutine accepts the input vector and window mask, # and will, for a specified subvector size, return the locations # and the values of pixels within the data window. This version # assumes that there IS a data window mask present. # ^^ # # Version Date Author Description # 27-JAN-1993 R. Williamson Converted to SPP # 13 7-DEC-1983 Pat Murphy Submitted for inspection # 3 30-AUG-1983 PAT MURPHY Cleverer way of scanning mask # 2 22-AUG-1983 PAT MURPHY add PDL and fortran # 1 22-AUG-1983 PAT MURPHY Prolog Generation # # # int dim # Size of input vector int rwidth # Size of output vectors int x[rwidth] # Output positions vector int total, i, halfsize # Local variables int nn, leftmost int status # Returned status real input[dim] # Input vector real wndo[dim] # Mask, assumed same size as input real rcentr # Location of center of range real y[rwidth] # Output values vector begin # Assume all is ok status = OK # If size of input array is exceeded if (rwidth > dim) { # Then user is asking too much of this # poor under-rated subroutine, so # quit now on the unscrupulous cretin status = FATAL return } # Store half the width of the range halfsize = rwidth/2 #Init the total number of good points total = 0 # Get the location of nearest point nn = int (rcentr + .5) # Init the loop pointer to this i = nn # Scan left of NN while (i >= 1 && total <= halfsize) { # If pixel is in the window mask if(wndo[i] == 0.0) { # Bump total number of valid pixels total = total + 1 # and construct map of their locations x[total] = i } # bump pointer down till we hit one or i = i - 1 # until we have enough points } # store point left of leftmost point leftmost = x[total] - 1 # Start searching beyond nearest point i = nn + 1 # Scan right of NN while (i <= dim && total < rwidth) { # If pixel is in the window mask if(wndo[i] == 0.0) { # Bump total number of valid pixels total = total + 1 # and construct map of their locations x[total] = i } # bump pointer up till we hit top of i = i + 1 # array or we have enough points } # One more step to do. If we have not got enough points, there may # be more on the left side beyond the leftmost point. If so, get them if (total < rwidth && leftmost > 0) { # Start scan at next pt i = leftmost # Scan left again while (i > 0 && total < rwidth) { # If pixel is in window if (wndo[i] == 0.0) { # Bump total #points total = total + 1 # record point position x[total] = i } # bump pointer down to next pt i = i - 1 # continue till we hit bottom or get } # enough points, whichever comes first } # If this is less than the width given if (total != rwidth) { # then we can't possibly extract that # many points so abort now status = FATAL return } # Need to call a sorting routine here # Sort this array in ascending order call asrti (x, x, total) # VOPS Sort routine # For each location in output subvectrs # the y value in the sub-vector do i = 1, rwidth { y[i] = input[x[i]] } end