This a schenmatic representation of the structure of the OCCULT-2 algorithm highlighting the four major steps.
def backgd_sup(image, zmin, qmed):
"""
Parameters:
image : numpy.ndarray (map data)
zmin : The minimum value of intensity which is allowed
qmed : The scaling factor with which the median is multiplied to fill the
values below ```zmin```
return : numpy.ndarray
Image with background supressed
"""
zmed = np.median(image_data)
image = np.where( image < zmin, qmed * zmed, image )
return image
The actual filtering routine will depend on which scipy filtering module we will be using. This is just a pseudocode.
def filter(image, nsm1, nsm2):
"""
Parameters:
image : <numpy.ndarray>
Background supressed image
nsm1 : <int>
Low pass filter constant. This must be odd.
nsm2 : <int>
High pass filter constant.
ns2-ns1 = 2 is the optimum choice
return : numpy.ndarray
"""
if(nsm1>=nsm2):
raise ValueError ("nsm1 should be less than nsm2")
result_image = band_pass_filter(image)
return result_image
def find_loop(image_data):
"""
image : <numpy.ndarray>
band passed image
returns <numpy.array>
array of the position of individual loops
"""
while(image.max() != 0): # until the entire image is zeroed out
pixel_pos = np.argwhere(image == image.max())
loop_coords = trace_loop(image, pixel_pos) # new data with the traced loop being zeroed out
image = subtract_loop(image, loop_coords)
return loop_coords # the array of the position of individual loops
def trace_loop(image_data, pix):
"""
image : <numpy.ndarray>
Processed image
pix : <np.array>
Loop start position [X,Y]
returns <numpy.array>
loop_coordinates
"""
# implement the algorithm as described in the paper
return s # loop_coordinates range(1,ns)
def subtract_loop(image,loop_coords):
"""
image : <numpy.ndarray>
Processed image
loop_coords : <numpy.ndarray>
Positions comprising a loop
returns : <numpy.ndarray>
Image with the loop subtracted
"""
image[loop_coords] = 0
return image