def backgd_sup(image_data, zmin, qmed =None):
"""
Parameters:
image_data : numpy.ndarray (map data)
qmed : Set by user (range [1,2.5])
if None : set qmed = 1
return : numpy.ndarray
"""
zmed = np.median(image_data)
low_intensity = np.argwhere(image_data < zmin)
image_data[low_intensity[:,0], low_intensity[:,1]] = zmed
return image_data
will depend on which scipy filtering module we will be using . For the time being I use smooth
def filter(image_data, nsm1, nsm2):
"""
Parameters:
image_data : Processed image <numpy.ndarray> (map.data)
nsm1 : low pass filter constant <int> or <float>
nsm2 : high pass filter constant <int> or <float>
return : numpy.ndarray
"""
if(nsm1>=nsm2):
print("nsm1 should be less than nsm2")
low_pass = scipy.smooth(image_data, nsm1)
high_pass = scipy.smooth(image_data, nsm2) # will depend on which scipy filtering module we will be using [](http://scipy-cookbook.readthedocs.io/items/SignalSmooth.html)
result_image = low_pass - high_pass
return result_image
def find_loop(image_data):
"""
image_data : Processed image <numpy.ndarray> (map.data)
returns array of the position of individual loops <numpy.array>
"""
while(max(image_data) != 0): # until the entire image is zeroed out
pixel_pos = np.argwhere(image_data == image_data.max())
image_data, loop_coords = trace_loop(image_data, pixel_pos) # new data with the traced loop being zeroed out
return loop_coords # the array of the position of individual loops
def trace_loop(image_data, pix):
"""
image_data : Processed image <numpy.ndarray> (map.data)
pix : loop start position [X,Y] <np.array>
returns loop_coordinates <numpy.array>
"""
# implement the algorithm as described in the paper
return s # loop_coordinates range(1,ns)
def subtract_loop(image_data,pix):
"""
image_data : Processed image <numpy.ndarray> (map.data)
pix : loop start position [X,Y] <np.array>
returns : <numpy.ndarray>
"""
w = (nsm2/2 -1) #nsm2 from filter function
s = trace_loop(image_data,pix)
for i in range(1,len(s)):
image_data[pix[0]+i+w][pix[1]+i+w] = 0 # setting to 0
image_data[pix[0]+i-w][pix[1]+i-w] = 0 # setting to 0
return image_data