repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
radjkarl/imgProcessor
imgProcessor/camera/NoiseLevelFunction.py
_validI
def _validI(x, y, weights): ''' return indices that have enough data points and are not erroneous ''' # density filter: i = np.logical_and(np.isfinite(y), weights > np.median(weights)) # filter outliers: try: grad = np.abs(np.gradient(y[i])) max_gradient = 4 * np.me...
python
def _validI(x, y, weights): ''' return indices that have enough data points and are not erroneous ''' # density filter: i = np.logical_and(np.isfinite(y), weights > np.median(weights)) # filter outliers: try: grad = np.abs(np.gradient(y[i])) max_gradient = 4 * np.me...
[ "def", "_validI", "(", "x", ",", "y", ",", "weights", ")", ":", "# density filter:\r", "i", "=", "np", ".", "logical_and", "(", "np", ".", "isfinite", "(", "y", ")", ",", "weights", ">", "np", ".", "median", "(", "weights", ")", ")", "# filter outlie...
return indices that have enough data points and are not erroneous
[ "return", "indices", "that", "have", "enough", "data", "points", "and", "are", "not", "erroneous" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L110-L123
radjkarl/imgProcessor
imgProcessor/camera/NoiseLevelFunction.py
smooth
def smooth(x, y, weights): ''' in case the NLF cannot be described by a square root function commit bounded polynomial interpolation ''' # Spline hard to smooth properly, therefore solfed with # bounded polynomal interpolation # ext=3: no extrapolation, but boundary value # ...
python
def smooth(x, y, weights): ''' in case the NLF cannot be described by a square root function commit bounded polynomial interpolation ''' # Spline hard to smooth properly, therefore solfed with # bounded polynomal interpolation # ext=3: no extrapolation, but boundary value # ...
[ "def", "smooth", "(", "x", ",", "y", ",", "weights", ")", ":", "# Spline hard to smooth properly, therefore solfed with\r", "# bounded polynomal interpolation\r", "# ext=3: no extrapolation, but boundary value\r", "# return UnivariateSpline(x, y, w=weights,\r", "# ...
in case the NLF cannot be described by a square root function commit bounded polynomial interpolation
[ "in", "case", "the", "NLF", "cannot", "be", "described", "by", "a", "square", "root", "function", "commit", "bounded", "polynomial", "interpolation" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L131-L150
radjkarl/imgProcessor
imgProcessor/camera/NoiseLevelFunction.py
oneImageNLF
def oneImageNLF(img, img2=None, signal=None): ''' Estimate the NLF from one or two images of the same kind ''' x, y, weights, signal = calcNLF(img, img2, signal) _, fn, _ = _evaluate(x, y, weights) return fn, signal
python
def oneImageNLF(img, img2=None, signal=None): ''' Estimate the NLF from one or two images of the same kind ''' x, y, weights, signal = calcNLF(img, img2, signal) _, fn, _ = _evaluate(x, y, weights) return fn, signal
[ "def", "oneImageNLF", "(", "img", ",", "img2", "=", "None", ",", "signal", "=", "None", ")", ":", "x", ",", "y", ",", "weights", ",", "signal", "=", "calcNLF", "(", "img", ",", "img2", ",", "signal", ")", "_", ",", "fn", ",", "_", "=", "_evalua...
Estimate the NLF from one or two images of the same kind
[ "Estimate", "the", "NLF", "from", "one", "or", "two", "images", "of", "the", "same", "kind" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L153-L159
radjkarl/imgProcessor
imgProcessor/camera/NoiseLevelFunction.py
_getMinMax
def _getMinMax(img): ''' Get the a range of image intensities that most pixels are in with ''' av = np.mean(img) std = np.std(img) # define range for segmentation: mn = av - 3 * std mx = av + 3 * std return max(img.min(), mn, 0), min(img.max(), mx)
python
def _getMinMax(img): ''' Get the a range of image intensities that most pixels are in with ''' av = np.mean(img) std = np.std(img) # define range for segmentation: mn = av - 3 * std mx = av + 3 * std return max(img.min(), mn, 0), min(img.max(), mx)
[ "def", "_getMinMax", "(", "img", ")", ":", "av", "=", "np", ".", "mean", "(", "img", ")", "std", "=", "np", ".", "std", "(", "img", ")", "# define range for segmentation:\r", "mn", "=", "av", "-", "3", "*", "std", "mx", "=", "av", "+", "3", "*", ...
Get the a range of image intensities that most pixels are in with
[ "Get", "the", "a", "range", "of", "image", "intensities", "that", "most", "pixels", "are", "in", "with" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L162-L173
radjkarl/imgProcessor
imgProcessor/camera/NoiseLevelFunction.py
calcNLF
def calcNLF(img, img2=None, signal=None, mn_mx_nbins=None, x=None, averageFn='AAD', signalFromMultipleImages=False): ''' Calculate the noise level function (NLF) as f(intensity) using one or two image. The approach for this work is published in JPV########## img2 - 2...
python
def calcNLF(img, img2=None, signal=None, mn_mx_nbins=None, x=None, averageFn='AAD', signalFromMultipleImages=False): ''' Calculate the noise level function (NLF) as f(intensity) using one or two image. The approach for this work is published in JPV########## img2 - 2...
[ "def", "calcNLF", "(", "img", ",", "img2", "=", "None", ",", "signal", "=", "None", ",", "mn_mx_nbins", "=", "None", ",", "x", "=", "None", ",", "averageFn", "=", "'AAD'", ",", "signalFromMultipleImages", "=", "False", ")", ":", "# CONSTANTS:\r", "# fact...
Calculate the noise level function (NLF) as f(intensity) using one or two image. The approach for this work is published in JPV########## img2 - 2nd image taken under same conditions used to estimate noise via image difference signalFromMultipleImages - whether the signal is an avera...
[ "Calculate", "the", "noise", "level", "function", "(", "NLF", ")", "as", "f", "(", "intensity", ")", "using", "one", "or", "two", "image", ".", "The", "approach", "for", "this", "work", "is", "published", "in", "JPV##########", "img2", "-", "2nd", "image...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L176-L271
radjkarl/imgProcessor
imgProcessor/interpolate/polyfit2d.py
polyfit2d
def polyfit2d(x, y, z, order=3 #bounds=None ): ''' fit unstructured data ''' ncols = (order + 1)**2 G = np.zeros((x.size, ncols)) ij = itertools.product(list(range(order+1)), list(range(order+1))) for k, (i,j) in enumerate(ij): G[:,k] = x**i * y**j m = np...
python
def polyfit2d(x, y, z, order=3 #bounds=None ): ''' fit unstructured data ''' ncols = (order + 1)**2 G = np.zeros((x.size, ncols)) ij = itertools.product(list(range(order+1)), list(range(order+1))) for k, (i,j) in enumerate(ij): G[:,k] = x**i * y**j m = np...
[ "def", "polyfit2d", "(", "x", ",", "y", ",", "z", ",", "order", "=", "3", "#bounds=None\r", ")", ":", "ncols", "=", "(", "order", "+", "1", ")", "**", "2", "G", "=", "np", ".", "zeros", "(", "(", "x", ".", "size", ",", "ncols", ")", ")", "i...
fit unstructured data
[ "fit", "unstructured", "data" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/polyfit2d.py#L8-L19
radjkarl/imgProcessor
imgProcessor/interpolate/polyfit2d.py
polyfit2dGrid
def polyfit2dGrid(arr, mask=None, order=3, replace_all=False, copy=True, outgrid=None): ''' replace all masked values with polynomial fitted ones ''' s0,s1 = arr.shape if mask is None: if outgrid is None: y,x = np.mgrid[:float(s0),:float(s1)] ...
python
def polyfit2dGrid(arr, mask=None, order=3, replace_all=False, copy=True, outgrid=None): ''' replace all masked values with polynomial fitted ones ''' s0,s1 = arr.shape if mask is None: if outgrid is None: y,x = np.mgrid[:float(s0),:float(s1)] ...
[ "def", "polyfit2dGrid", "(", "arr", ",", "mask", "=", "None", ",", "order", "=", "3", ",", "replace_all", "=", "False", ",", "copy", "=", "True", ",", "outgrid", "=", "None", ")", ":", "s0", ",", "s1", "=", "arr", ".", "shape", "if", "mask", "is"...
replace all masked values with polynomial fitted ones
[ "replace", "all", "masked", "values", "with", "polynomial", "fitted", "ones" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/polyfit2d.py#L31-L65
radjkarl/imgProcessor
imgProcessor/features/minimumLineInArray.py
minimumLineInArray
def minimumLineInArray(arr, relative=False, f=0, refinePosition=True, max_pos=100, return_pos_arr=False, # order=2 ): ''' find closest minimum position next to middle line relative: ret...
python
def minimumLineInArray(arr, relative=False, f=0, refinePosition=True, max_pos=100, return_pos_arr=False, # order=2 ): ''' find closest minimum position next to middle line relative: ret...
[ "def", "minimumLineInArray", "(", "arr", ",", "relative", "=", "False", ",", "f", "=", "0", ",", "refinePosition", "=", "True", ",", "max_pos", "=", "100", ",", "return_pos_arr", "=", "False", ",", "# order=2\r", ")", ":", "s0", ",", "s1", "=", "arr", ...
find closest minimum position next to middle line relative: return position relative to middle line f: relative decrease (0...1) - setting this value close to one will discriminate positions further away from the center ##order: 2 for cubic refinement
[ "find", "closest", "minimum", "position", "next", "to", "middle", "line", "relative", ":", "return", "position", "relative", "to", "middle", "line", "f", ":", "relative", "decrease", "(", "0", "...", "1", ")", "-", "setting", "this", "value", "close", "to"...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/minimumLineInArray.py#L27-L72
radjkarl/imgProcessor
imgProcessor/filters/FourierFilter.py
FourierFilter.highPassFilter
def highPassFilter(self, threshold): ''' remove all low frequencies by setting a square in the middle of the Fourier transformation of the size (2*threshold)^2 to zero threshold = 0...1 ''' if not threshold: return rows, cols = self.img.shape ...
python
def highPassFilter(self, threshold): ''' remove all low frequencies by setting a square in the middle of the Fourier transformation of the size (2*threshold)^2 to zero threshold = 0...1 ''' if not threshold: return rows, cols = self.img.shape ...
[ "def", "highPassFilter", "(", "self", ",", "threshold", ")", ":", "if", "not", "threshold", ":", "return", "rows", ",", "cols", "=", "self", ".", "img", ".", "shape", "tx", "=", "int", "(", "cols", "*", "threshold", ")", "ty", "=", "int", "(", "row...
remove all low frequencies by setting a square in the middle of the Fourier transformation of the size (2*threshold)^2 to zero threshold = 0...1
[ "remove", "all", "low", "frequencies", "by", "setting", "a", "square", "in", "the", "middle", "of", "the", "Fourier", "transformation", "of", "the", "size", "(", "2", "*", "threshold", ")", "^2", "to", "zero", "threshold", "=", "0", "...", "1" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L27-L41
radjkarl/imgProcessor
imgProcessor/filters/FourierFilter.py
FourierFilter.lowPassFilter
def lowPassFilter(self, threshold): ''' remove all high frequencies by setting boundary around a quarry in the middle of the size (2*threshold)^2 to zero threshold = 0...1 ''' if not threshold: return rows, cols = self.img.shape tx = i...
python
def lowPassFilter(self, threshold): ''' remove all high frequencies by setting boundary around a quarry in the middle of the size (2*threshold)^2 to zero threshold = 0...1 ''' if not threshold: return rows, cols = self.img.shape tx = i...
[ "def", "lowPassFilter", "(", "self", ",", "threshold", ")", ":", "if", "not", "threshold", ":", "return", "rows", ",", "cols", "=", "self", ".", "img", ".", "shape", "tx", "=", "int", "(", "cols", "*", "threshold", "*", "0.25", ")", "ty", "=", "int...
remove all high frequencies by setting boundary around a quarry in the middle of the size (2*threshold)^2 to zero threshold = 0...1
[ "remove", "all", "high", "frequencies", "by", "setting", "boundary", "around", "a", "quarry", "in", "the", "middle", "of", "the", "size", "(", "2", "*", "threshold", ")", "^2", "to", "zero", "threshold", "=", "0", "...", "1" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L43-L61
radjkarl/imgProcessor
imgProcessor/filters/FourierFilter.py
FourierFilter.reconstructImage
def reconstructImage(self): ''' do inverse Fourier transform and return result ''' f_ishift = np.fft.ifftshift(self.fshift) return np.real(np.fft.ifft2(f_ishift))
python
def reconstructImage(self): ''' do inverse Fourier transform and return result ''' f_ishift = np.fft.ifftshift(self.fshift) return np.real(np.fft.ifft2(f_ishift))
[ "def", "reconstructImage", "(", "self", ")", ":", "f_ishift", "=", "np", ".", "fft", ".", "ifftshift", "(", "self", ".", "fshift", ")", "return", "np", ".", "real", "(", "np", ".", "fft", ".", "ifft2", "(", "f_ishift", ")", ")" ]
do inverse Fourier transform and return result
[ "do", "inverse", "Fourier", "transform", "and", "return", "result" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/FourierFilter.py#L108-L113
radjkarl/imgProcessor
imgProcessor/interpolate/interpolate2dUnstructuredIDW.py
interpolate2dUnstructuredIDW
def interpolate2dUnstructuredIDW(x, y, v, grid, power=2): ''' x,y,v --> 1d numpy.array grid --> 2d numpy.array fast if number of given values is small relative to grid resolution ''' n = len(v) gx = grid.shape[0] gy = grid.shape[1] for i in range(gx): for j in ran...
python
def interpolate2dUnstructuredIDW(x, y, v, grid, power=2): ''' x,y,v --> 1d numpy.array grid --> 2d numpy.array fast if number of given values is small relative to grid resolution ''' n = len(v) gx = grid.shape[0] gy = grid.shape[1] for i in range(gx): for j in ran...
[ "def", "interpolate2dUnstructuredIDW", "(", "x", ",", "y", ",", "v", ",", "grid", ",", "power", "=", "2", ")", ":", "n", "=", "len", "(", "v", ")", "gx", "=", "grid", ".", "shape", "[", "0", "]", "gy", "=", "grid", ".", "shape", "[", "1", "]"...
x,y,v --> 1d numpy.array grid --> 2d numpy.array fast if number of given values is small relative to grid resolution
[ "x", "y", "v", "--", ">", "1d", "numpy", ".", "array", "grid", "--", ">", "2d", "numpy", ".", "array", "fast", "if", "number", "of", "given", "values", "is", "small", "relative", "to", "grid", "resolution" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dUnstructuredIDW.py#L8-L38
radjkarl/imgProcessor
imgProcessor/features/hog.py
hog
def hog(image, orientations=8, ksize=(5, 5)): ''' returns the Histogram of Oriented Gradients :param ksize: convolution kernel size as (y,x) - needs to be odd :param orientations: number of orientations in between rad=0 and rad=pi similar to http://scikit-image.org/docs/dev/auto_examples/pl...
python
def hog(image, orientations=8, ksize=(5, 5)): ''' returns the Histogram of Oriented Gradients :param ksize: convolution kernel size as (y,x) - needs to be odd :param orientations: number of orientations in between rad=0 and rad=pi similar to http://scikit-image.org/docs/dev/auto_examples/pl...
[ "def", "hog", "(", "image", ",", "orientations", "=", "8", ",", "ksize", "=", "(", "5", ",", "5", ")", ")", ":", "s0", ",", "s1", "=", "image", ".", "shape", "[", ":", "2", "]", "# speed up the process through saving generated kernels:\r", "try", ":", ...
returns the Histogram of Oriented Gradients :param ksize: convolution kernel size as (y,x) - needs to be odd :param orientations: number of orientations in between rad=0 and rad=pi similar to http://scikit-image.org/docs/dev/auto_examples/plot_hog.html but faster and with less options
[ "returns", "the", "Histogram", "of", "Oriented", "Gradients", ":", "param", "ksize", ":", "convolution", "kernel", "size", "as", "(", "y", "x", ")", "-", "needs", "to", "be", "odd", ":", "param", "orientations", ":", "number", "of", "orientations", "in", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/hog.py#L40-L64
radjkarl/imgProcessor
imgProcessor/features/hog.py
visualize
def visualize(hog, grid=(10, 10), radCircle=None): ''' visualize HOG as polynomial around cell center for [grid] * cells ''' s0, s1, nang = hog.shape angles = np.linspace(0, np.pi, nang + 1)[:-1] # center of each sub array: cx, cy = s0 // (2 * grid[0]), s1 // (2 * grid[1]) ...
python
def visualize(hog, grid=(10, 10), radCircle=None): ''' visualize HOG as polynomial around cell center for [grid] * cells ''' s0, s1, nang = hog.shape angles = np.linspace(0, np.pi, nang + 1)[:-1] # center of each sub array: cx, cy = s0 // (2 * grid[0]), s1 // (2 * grid[1]) ...
[ "def", "visualize", "(", "hog", ",", "grid", "=", "(", "10", ",", "10", ")", ",", "radCircle", "=", "None", ")", ":", "s0", ",", "s1", ",", "nang", "=", "hog", ".", "shape", "angles", "=", "np", ".", "linspace", "(", "0", ",", "np", ".", "pi"...
visualize HOG as polynomial around cell center for [grid] * cells
[ "visualize", "HOG", "as", "polynomial", "around", "cell", "center", "for", "[", "grid", "]", "*", "cells" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/hog.py#L68-L105
radjkarl/imgProcessor
imgProcessor/camera/flatField/postProcessing.py
postProcessing
def postProcessing(arr, method='KW replace + Gauss', mask=None): ''' Post process measured flat field [arr]. Depending on the measurement, different post processing [method]s are beneficial. The available methods are presented in --- K.Bedrich, M.Bokalic et al.: ...
python
def postProcessing(arr, method='KW replace + Gauss', mask=None): ''' Post process measured flat field [arr]. Depending on the measurement, different post processing [method]s are beneficial. The available methods are presented in --- K.Bedrich, M.Bokalic et al.: ...
[ "def", "postProcessing", "(", "arr", ",", "method", "=", "'KW replace + Gauss'", ",", "mask", "=", "None", ")", ":", "assert", "method", "in", "ppMETHODS", ",", "'post processing method (%s) must be one of %s'", "%", "(", "method", ",", "ppMETHODS", ")", "if", "...
Post process measured flat field [arr]. Depending on the measurement, different post processing [method]s are beneficial. The available methods are presented in --- K.Bedrich, M.Bokalic et al.: ELECTROLUMINESCENCE IMAGING OF PV DEVICES: ADVANCED FLAT FIELD CALI...
[ "Post", "process", "measured", "flat", "field", "[", "arr", "]", ".", "Depending", "on", "the", "measurement", "different", "post", "processing", "[", "method", "]", "s", "are", "beneficial", ".", "The", "available", "methods", "are", "presented", "in", "---...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/postProcessing.py#L16-L74
radjkarl/imgProcessor
imgProcessor/transform/rmBorder.py
rmBorder
def rmBorder(img, border=None): ''' border [None], if images are corrected and device ends at image border [one number] (like 50), if there is an equally spaced border aroun...
python
def rmBorder(img, border=None): ''' border [None], if images are corrected and device ends at image border [one number] (like 50), if there is an equally spaced border aroun...
[ "def", "rmBorder", "(", "img", ",", "border", "=", "None", ")", ":", "if", "border", "is", "None", ":", "pass", "elif", "len", "(", "border", ")", "==", "2", ":", "s0", "=", "slice", "(", "border", "[", "0", "]", "[", "1", "]", ",", "border", ...
border [None], if images are corrected and device ends at image border [one number] (like 50), if there is an equally spaced border around the device [two tu...
[ "border", "[", "None", "]", "if", "images", "are", "corrected", "and", "device", "ends", "at", "image", "border", "[", "one", "number", "]", "(", "like", "50", ")", "if", "there", "is", "an", "equally", "spaced", "border", "around", "the", "device", "[...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/rmBorder.py#L6-L36
radjkarl/imgProcessor
imgProcessor/features/SingleTimeEffectDetection.py
SingleTimeEffectDetection.addImage
def addImage(self, image, mask=None): ''' ######### mask -- optional ''' self._last_diff = diff = image - self.noSTE ste = diff > self.threshold removeSinglePixels(ste) self.mask_clean = clean = ~ste if mask is not None: ...
python
def addImage(self, image, mask=None): ''' ######### mask -- optional ''' self._last_diff = diff = image - self.noSTE ste = diff > self.threshold removeSinglePixels(ste) self.mask_clean = clean = ~ste if mask is not None: ...
[ "def", "addImage", "(", "self", ",", "image", ",", "mask", "=", "None", ")", ":", "self", ".", "_last_diff", "=", "diff", "=", "image", "-", "self", ".", "noSTE", "ste", "=", "diff", ">", "self", ".", "threshold", "removeSinglePixels", "(", "ste", ")...
######### mask -- optional
[ "#########", "mask", "--", "optional" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L55-L75
radjkarl/imgProcessor
imgProcessor/features/SingleTimeEffectDetection.py
SingleTimeEffectDetection.relativeAreaSTE
def relativeAreaSTE(self): ''' return STE area - relative to image area ''' s = self.noSTE.shape return np.sum(self.mask_STE) / (s[0] * s[1])
python
def relativeAreaSTE(self): ''' return STE area - relative to image area ''' s = self.noSTE.shape return np.sum(self.mask_STE) / (s[0] * s[1])
[ "def", "relativeAreaSTE", "(", "self", ")", ":", "s", "=", "self", ".", "noSTE", ".", "shape", "return", "np", ".", "sum", "(", "self", ".", "mask_STE", ")", "/", "(", "s", "[", "0", "]", "*", "s", "[", "1", "]", ")" ]
return STE area - relative to image area
[ "return", "STE", "area", "-", "relative", "to", "image", "area" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L83-L88
radjkarl/imgProcessor
imgProcessor/features/SingleTimeEffectDetection.py
SingleTimeEffectDetection.intensityDistributionSTE
def intensityDistributionSTE(self, bins=10, range=None): ''' return distribution of STE intensity ''' v = np.abs(self._last_diff[self.mask_STE]) return np.histogram(v, bins, range)
python
def intensityDistributionSTE(self, bins=10, range=None): ''' return distribution of STE intensity ''' v = np.abs(self._last_diff[self.mask_STE]) return np.histogram(v, bins, range)
[ "def", "intensityDistributionSTE", "(", "self", ",", "bins", "=", "10", ",", "range", "=", "None", ")", ":", "v", "=", "np", ".", "abs", "(", "self", ".", "_last_diff", "[", "self", ".", "mask_STE", "]", ")", "return", "np", ".", "histogram", "(", ...
return distribution of STE intensity
[ "return", "distribution", "of", "STE", "intensity" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/SingleTimeEffectDetection.py#L90-L95
radjkarl/imgProcessor
imgProcessor/transformations.py
toUIntArray
def toUIntArray(img, dtype=None, cutNegative=True, cutHigh=True, range=None, copy=True): ''' transform a float to an unsigned integer array of a fitting dtype adds an offset, to get rid of negative values range = (min, max) - scale values between given range cutNegative - a...
python
def toUIntArray(img, dtype=None, cutNegative=True, cutHigh=True, range=None, copy=True): ''' transform a float to an unsigned integer array of a fitting dtype adds an offset, to get rid of negative values range = (min, max) - scale values between given range cutNegative - a...
[ "def", "toUIntArray", "(", "img", ",", "dtype", "=", "None", ",", "cutNegative", "=", "True", ",", "cutHigh", "=", "True", ",", "range", "=", "None", ",", "copy", "=", "True", ")", ":", "mn", ",", "mx", "=", "None", ",", "None", "if", "range", "i...
transform a float to an unsigned integer array of a fitting dtype adds an offset, to get rid of negative values range = (min, max) - scale values between given range cutNegative - all values <0 will be set to 0 cutHigh - set to False to rather scale values to fit
[ "transform", "a", "float", "to", "an", "unsigned", "integer", "array", "of", "a", "fitting", "dtype", "adds", "an", "offset", "to", "get", "rid", "of", "negative", "values", "range", "=", "(", "min", "max", ")", "-", "scale", "values", "between", "given"...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L11-L75
radjkarl/imgProcessor
imgProcessor/transformations.py
toFloatArray
def toFloatArray(img): ''' transform an unsigned integer array into a float array of the right size ''' _D = {1: np.float32, # uint8 2: np.float32, # uint16 4: np.float64, # uint32 8: np.float64} # uint64 return img.astype(_D[img.itemsize])
python
def toFloatArray(img): ''' transform an unsigned integer array into a float array of the right size ''' _D = {1: np.float32, # uint8 2: np.float32, # uint16 4: np.float64, # uint32 8: np.float64} # uint64 return img.astype(_D[img.itemsize])
[ "def", "toFloatArray", "(", "img", ")", ":", "_D", "=", "{", "1", ":", "np", ".", "float32", ",", "# uint8\r", "2", ":", "np", ".", "float32", ",", "# uint16\r", "4", ":", "np", ".", "float64", ",", "# uint32\r", "8", ":", "np", ".", "float64", "...
transform an unsigned integer array into a float array of the right size
[ "transform", "an", "unsigned", "integer", "array", "into", "a", "float", "array", "of", "the", "right", "size" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L78-L87
radjkarl/imgProcessor
imgProcessor/transformations.py
toNoUintArray
def toNoUintArray(arr): ''' cast array to the next higher integer array if dtype=unsigned integer ''' d = arr.dtype if d.kind == 'u': arr = arr.astype({1: np.int16, 2: np.int32, 4: np.int64}[d.itemsize]) return arr
python
def toNoUintArray(arr): ''' cast array to the next higher integer array if dtype=unsigned integer ''' d = arr.dtype if d.kind == 'u': arr = arr.astype({1: np.int16, 2: np.int32, 4: np.int64}[d.itemsize]) return arr
[ "def", "toNoUintArray", "(", "arr", ")", ":", "d", "=", "arr", ".", "dtype", "if", "d", ".", "kind", "==", "'u'", ":", "arr", "=", "arr", ".", "astype", "(", "{", "1", ":", "np", ".", "int16", ",", "2", ":", "np", ".", "int32", ",", "4", ":...
cast array to the next higher integer array if dtype=unsigned integer
[ "cast", "array", "to", "the", "next", "higher", "integer", "array", "if", "dtype", "=", "unsigned", "integer" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L90-L100
radjkarl/imgProcessor
imgProcessor/transformations.py
toGray
def toGray(img): ''' weights see https://en.wikipedia.org/wiki/Grayscale#Colorimetric_.28luminance-prese http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor ''' return np.average(img, axis=-1, weights=(0.299, # red ...
python
def toGray(img): ''' weights see https://en.wikipedia.org/wiki/Grayscale#Colorimetric_.28luminance-prese http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor ''' return np.average(img, axis=-1, weights=(0.299, # red ...
[ "def", "toGray", "(", "img", ")", ":", "return", "np", ".", "average", "(", "img", ",", "axis", "=", "-", "1", ",", "weights", "=", "(", "0.299", ",", "# red\r", "0.587", ",", "# green\r", "0.114", ")", "# blue\r", ")", ".", "astype", "(", "img", ...
weights see https://en.wikipedia.org/wiki/Grayscale#Colorimetric_.28luminance-prese http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor
[ "weights", "see", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Grayscale#Colorimetric_", ".", "28luminance", "-", "prese", "http", ":", "//", "docs", ".", "opencv", ".", "org", "/", "2", ".", "4", "/", "modules", "/", "i...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L126-L135
radjkarl/imgProcessor
imgProcessor/transformations.py
rgChromaticity
def rgChromaticity(img): ''' returns the normalized RGB space (RGB/intensity) see https://en.wikipedia.org/wiki/Rg_chromaticity ''' out = _calc(img) if img.dtype == np.uint8: out = (255 * out).astype(np.uint8) return out
python
def rgChromaticity(img): ''' returns the normalized RGB space (RGB/intensity) see https://en.wikipedia.org/wiki/Rg_chromaticity ''' out = _calc(img) if img.dtype == np.uint8: out = (255 * out).astype(np.uint8) return out
[ "def", "rgChromaticity", "(", "img", ")", ":", "out", "=", "_calc", "(", "img", ")", "if", "img", ".", "dtype", "==", "np", ".", "uint8", ":", "out", "=", "(", "255", "*", "out", ")", ".", "astype", "(", "np", ".", "uint8", ")", "return", "out"...
returns the normalized RGB space (RGB/intensity) see https://en.wikipedia.org/wiki/Rg_chromaticity
[ "returns", "the", "normalized", "RGB", "space", "(", "RGB", "/", "intensity", ")", "see", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Rg_chromaticity" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L138-L146
radjkarl/imgProcessor
imgProcessor/transformations.py
monochromaticWavelength
def monochromaticWavelength(img): ''' TODO########## ''' # peak wave lengths: https://en.wikipedia.org/wiki/RGB_color_model out = _calc(img) peakWavelengths = (570, 540, 440) # (r,g,b) # s = sum(peakWavelengths) for n, p in enumerate(peakWavelengths): out[..., n] *= p...
python
def monochromaticWavelength(img): ''' TODO########## ''' # peak wave lengths: https://en.wikipedia.org/wiki/RGB_color_model out = _calc(img) peakWavelengths = (570, 540, 440) # (r,g,b) # s = sum(peakWavelengths) for n, p in enumerate(peakWavelengths): out[..., n] *= p...
[ "def", "monochromaticWavelength", "(", "img", ")", ":", "# peak wave lengths: https://en.wikipedia.org/wiki/RGB_color_model\r", "out", "=", "_calc", "(", "img", ")", "peakWavelengths", "=", "(", "570", ",", "540", ",", "440", ")", "# (r,g,b)\r", "# s = sum(peakWavel...
TODO##########
[ "TODO##########" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L157-L168
radjkarl/imgProcessor
imgProcessor/transformations.py
rot90
def rot90(img): ''' rotate one or multiple grayscale or color images 90 degrees ''' s = img.shape if len(s) == 3: if s[2] in (3, 4): # color image out = np.empty((s[1], s[0], s[2]), dtype=img.dtype) for i in range(s[2]): out[:, :, i] = np.rot...
python
def rot90(img): ''' rotate one or multiple grayscale or color images 90 degrees ''' s = img.shape if len(s) == 3: if s[2] in (3, 4): # color image out = np.empty((s[1], s[0], s[2]), dtype=img.dtype) for i in range(s[2]): out[:, :, i] = np.rot...
[ "def", "rot90", "(", "img", ")", ":", "s", "=", "img", ".", "shape", "if", "len", "(", "s", ")", "==", "3", ":", "if", "s", "[", "2", "]", "in", "(", "3", ",", "4", ")", ":", "# color image\r", "out", "=", "np", ".", "empty", "(", "(", "s...
rotate one or multiple grayscale or color images 90 degrees
[ "rotate", "one", "or", "multiple", "grayscale", "or", "color", "images", "90", "degrees" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L186-L209
radjkarl/imgProcessor
imgProcessor/transformations.py
applyColorMap
def applyColorMap(gray, cmap='flame'): ''' like cv2.applyColorMap(im_gray, cv2.COLORMAP_*) but with different color maps ''' # TODO:implement more cmaps if cmap != 'flame': raise NotImplemented # TODO: make better mx = 256 # if gray.dtype==np.uint8 else 65535 lut = np.e...
python
def applyColorMap(gray, cmap='flame'): ''' like cv2.applyColorMap(im_gray, cv2.COLORMAP_*) but with different color maps ''' # TODO:implement more cmaps if cmap != 'flame': raise NotImplemented # TODO: make better mx = 256 # if gray.dtype==np.uint8 else 65535 lut = np.e...
[ "def", "applyColorMap", "(", "gray", ",", "cmap", "=", "'flame'", ")", ":", "# TODO:implement more cmaps\r", "if", "cmap", "!=", "'flame'", ":", "raise", "NotImplemented", "# TODO: make better\r", "mx", "=", "256", "# if gray.dtype==np.uint8 else 65535\r", "lut", "=",...
like cv2.applyColorMap(im_gray, cv2.COLORMAP_*) but with different color maps
[ "like", "cv2", ".", "applyColorMap", "(", "im_gray", "cv2", ".", "COLORMAP_", "*", ")", "but", "with", "different", "color", "maps" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L212-L246
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
_insertDateIndex
def _insertDateIndex(date, l): ''' returns the index to insert the given date in a list where each items first value is a date ''' return next((i for i, n in enumerate(l) if n[0] < date), len(l))
python
def _insertDateIndex(date, l): ''' returns the index to insert the given date in a list where each items first value is a date ''' return next((i for i, n in enumerate(l) if n[0] < date), len(l))
[ "def", "_insertDateIndex", "(", "date", ",", "l", ")", ":", "return", "next", "(", "(", "i", "for", "i", ",", "n", "in", "enumerate", "(", "l", ")", "if", "n", "[", "0", "]", "<", "date", ")", ",", "len", "(", "l", ")", ")" ]
returns the index to insert the given date in a list where each items first value is a date
[ "returns", "the", "index", "to", "insert", "the", "given", "date", "in", "a", "list", "where", "each", "items", "first", "value", "is", "a", "date" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L29-L34
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
_getFromDate
def _getFromDate(l, date): ''' returns the index of given or best fitting date ''' try: date = _toDate(date) i = _insertDateIndex(date, l) - 1 if i == -1: return l[0] return l[i] except (ValueError, TypeError): # ValueError: date invalid...
python
def _getFromDate(l, date): ''' returns the index of given or best fitting date ''' try: date = _toDate(date) i = _insertDateIndex(date, l) - 1 if i == -1: return l[0] return l[i] except (ValueError, TypeError): # ValueError: date invalid...
[ "def", "_getFromDate", "(", "l", ",", "date", ")", ":", "try", ":", "date", "=", "_toDate", "(", "date", ")", "i", "=", "_insertDateIndex", "(", "date", ",", "l", ")", "-", "1", "if", "i", "==", "-", "1", ":", "return", "l", "[", "0", "]", "r...
returns the index of given or best fitting date
[ "returns", "the", "index", "of", "given", "or", "best", "fitting", "date" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L37-L49
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.dates
def dates(self, typ, light=None): ''' Args: typ: type of calibration to look for. See .coeffs.keys() for all types available light (Optional[str]): restrict to calibrations, done given light source Returns: list: All calibration dates available for giv...
python
def dates(self, typ, light=None): ''' Args: typ: type of calibration to look for. See .coeffs.keys() for all types available light (Optional[str]): restrict to calibrations, done given light source Returns: list: All calibration dates available for giv...
[ "def", "dates", "(", "self", ",", "typ", ",", "light", "=", "None", ")", ":", "try", ":", "d", "=", "self", ".", "_getDate", "(", "typ", ",", "light", ")", "return", "[", "self", ".", "_toDateStr", "(", "c", "[", "0", "]", ")", "for", "c", "i...
Args: typ: type of calibration to look for. See .coeffs.keys() for all types available light (Optional[str]): restrict to calibrations, done given light source Returns: list: All calibration dates available for given typ
[ "Args", ":", "typ", ":", "type", "of", "calibration", "to", "look", "for", ".", "See", ".", "coeffs", ".", "keys", "()", "for", "all", "types", "available", "light", "(", "Optional", "[", "str", "]", ")", ":", "restrict", "to", "calibrations", "done", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L91-L104
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.infos
def infos(self, typ, light=None, date=None): ''' Args: typ: type of calibration to look for. See .coeffs.keys() for all types available date (Optional[str]): date of calibration Returns: list: all infos available for given typ ''' d =...
python
def infos(self, typ, light=None, date=None): ''' Args: typ: type of calibration to look for. See .coeffs.keys() for all types available date (Optional[str]): date of calibration Returns: list: all infos available for given typ ''' d =...
[ "def", "infos", "(", "self", ",", "typ", ",", "light", "=", "None", ",", "date", "=", "None", ")", ":", "d", "=", "self", ".", "_getDate", "(", "typ", ",", "light", ")", "if", "date", "is", "None", ":", "return", "[", "c", "[", "1", "]", "for...
Args: typ: type of calibration to look for. See .coeffs.keys() for all types available date (Optional[str]): date of calibration Returns: list: all infos available for given typ
[ "Args", ":", "typ", ":", "type", "of", "calibration", "to", "look", "for", ".", "See", ".", "coeffs", ".", "keys", "()", "for", "all", "types", "available", "date", "(", "Optional", "[", "str", "]", ")", ":", "date", "of", "calibration", "Returns", "...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L106-L119
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.overview
def overview(self): ''' Returns: str: an overview covering all calibrations infos and shapes ''' c = self.coeffs out = 'camera name: %s' % c['name'] out += '\nmax value: %s' % c['depth'] out += '\nlight spectra: %s' % c['light spe...
python
def overview(self): ''' Returns: str: an overview covering all calibrations infos and shapes ''' c = self.coeffs out = 'camera name: %s' % c['name'] out += '\nmax value: %s' % c['depth'] out += '\nlight spectra: %s' % c['light spe...
[ "def", "overview", "(", "self", ")", ":", "c", "=", "self", ".", "coeffs", "out", "=", "'camera name: %s'", "%", "c", "[", "'name'", "]", "out", "+=", "'\\nmax value: %s'", "%", "c", "[", "'depth'", "]", "out", "+=", "'\\nlight spectra: %s'", "%", "c", ...
Returns: str: an overview covering all calibrations infos and shapes
[ "Returns", ":", "str", ":", "an", "overview", "covering", "all", "calibrations", "infos", "and", "shapes" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L121-L164
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.setCamera
def setCamera(self, camera_name, bit_depth=16): ''' Args: camera_name (str): Name of the camera bit_depth (int): depth (bit) of the camera sensor ''' self.coeffs['name'] = camera_name self.coeffs['depth'] = bit_depth
python
def setCamera(self, camera_name, bit_depth=16): ''' Args: camera_name (str): Name of the camera bit_depth (int): depth (bit) of the camera sensor ''' self.coeffs['name'] = camera_name self.coeffs['depth'] = bit_depth
[ "def", "setCamera", "(", "self", ",", "camera_name", ",", "bit_depth", "=", "16", ")", ":", "self", ".", "coeffs", "[", "'name'", "]", "=", "camera_name", "self", ".", "coeffs", "[", "'depth'", "]", "=", "bit_depth" ]
Args: camera_name (str): Name of the camera bit_depth (int): depth (bit) of the camera sensor
[ "Args", ":", "camera_name", "(", "str", ")", ":", "Name", "of", "the", "camera", "bit_depth", "(", "int", ")", ":", "depth", "(", "bit", ")", "of", "the", "camera", "sensor" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L178-L185
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.addDarkCurrent
def addDarkCurrent(self, slope, intercept=None, date=None, info='', error=None): ''' Args: slope (np.array) intercept (np.array) error (numpy.array) slope (float): dPx/dExposureTime[sec] error (float): absolute date (str): "...
python
def addDarkCurrent(self, slope, intercept=None, date=None, info='', error=None): ''' Args: slope (np.array) intercept (np.array) error (numpy.array) slope (float): dPx/dExposureTime[sec] error (float): absolute date (str): "...
[ "def", "addDarkCurrent", "(", "self", ",", "slope", ",", "intercept", "=", "None", ",", "date", "=", "None", ",", "info", "=", "''", ",", "error", "=", "None", ")", ":", "date", "=", "_toDate", "(", "date", ")", "self", ".", "_checkShape", "(", "sl...
Args: slope (np.array) intercept (np.array) error (numpy.array) slope (float): dPx/dExposureTime[sec] error (float): absolute date (str): "DD Mon YY" e.g. "30 Nov 16"
[ "Args", ":", "slope", "(", "np", ".", "array", ")", "intercept", "(", "np", ".", "array", ")", "error", "(", "numpy", ".", "array", ")", "slope", "(", "float", ")", ":", "dPx", "/", "dExposureTime", "[", "sec", "]", "error", "(", "float", ")", ":...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L187-L207
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.addNoise
def addNoise(self, nlf_coeff, date=None, info='', error=None): ''' Args: nlf_coeff (list) error (float): absolute info (str): additional information date (str): "DD Mon YY" e.g. "30 Nov 16" ''' date = _toDate(date) d = self...
python
def addNoise(self, nlf_coeff, date=None, info='', error=None): ''' Args: nlf_coeff (list) error (float): absolute info (str): additional information date (str): "DD Mon YY" e.g. "30 Nov 16" ''' date = _toDate(date) d = self...
[ "def", "addNoise", "(", "self", ",", "nlf_coeff", ",", "date", "=", "None", ",", "info", "=", "''", ",", "error", "=", "None", ")", ":", "date", "=", "_toDate", "(", "date", ")", "d", "=", "self", ".", "coeffs", "[", "'noise'", "]", "d", ".", "...
Args: nlf_coeff (list) error (float): absolute info (str): additional information date (str): "DD Mon YY" e.g. "30 Nov 16"
[ "Args", ":", "nlf_coeff", "(", "list", ")", "error", "(", "float", ")", ":", "absolute", "info", "(", "str", ")", ":", "additional", "information", "date", "(", "str", ")", ":", "DD", "Mon", "YY", "e", ".", "g", ".", "30", "Nov", "16" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L209-L219
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.addPSF
def addPSF(self, psf, date=None, info='', light_spectrum='visible'): ''' add a new point spread function ''' self._registerLight(light_spectrum) date = _toDate(date) f = self.coeffs['psf'] if light_spectrum not in f: f[light_spectrum] = [] ...
python
def addPSF(self, psf, date=None, info='', light_spectrum='visible'): ''' add a new point spread function ''' self._registerLight(light_spectrum) date = _toDate(date) f = self.coeffs['psf'] if light_spectrum not in f: f[light_spectrum] = [] ...
[ "def", "addPSF", "(", "self", ",", "psf", ",", "date", "=", "None", ",", "info", "=", "''", ",", "light_spectrum", "=", "'visible'", ")", ":", "self", ".", "_registerLight", "(", "light_spectrum", ")", "date", "=", "_toDate", "(", "date", ")", "f", "...
add a new point spread function
[ "add", "a", "new", "point", "spread", "function" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L232-L243
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.addFlatField
def addFlatField(self, arr, date=None, info='', error=None, light_spectrum='visible'): ''' light_spectrum = light, IR ... ''' self._registerLight(light_spectrum) self._checkShape(arr) date = _toDate(date) f = self.coeffs['flat field'] ...
python
def addFlatField(self, arr, date=None, info='', error=None, light_spectrum='visible'): ''' light_spectrum = light, IR ... ''' self._registerLight(light_spectrum) self._checkShape(arr) date = _toDate(date) f = self.coeffs['flat field'] ...
[ "def", "addFlatField", "(", "self", ",", "arr", ",", "date", "=", "None", ",", "info", "=", "''", ",", "error", "=", "None", ",", "light_spectrum", "=", "'visible'", ")", ":", "self", ".", "_registerLight", "(", "light_spectrum", ")", "self", ".", "_ch...
light_spectrum = light, IR ...
[ "light_spectrum", "=", "light", "IR", "..." ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L255-L267
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.addLens
def addLens(self, lens, date=None, info='', light_spectrum='visible'): ''' lens -> instance of LensDistortion or saved file ''' self._registerLight(light_spectrum) date = _toDate(date) if not isinstance(lens, LensDistortion): l = LensDistortion() ...
python
def addLens(self, lens, date=None, info='', light_spectrum='visible'): ''' lens -> instance of LensDistortion or saved file ''' self._registerLight(light_spectrum) date = _toDate(date) if not isinstance(lens, LensDistortion): l = LensDistortion() ...
[ "def", "addLens", "(", "self", ",", "lens", ",", "date", "=", "None", ",", "info", "=", "''", ",", "light_spectrum", "=", "'visible'", ")", ":", "self", ".", "_registerLight", "(", "light_spectrum", ")", "date", "=", "_toDate", "(", "date", ")", "if", ...
lens -> instance of LensDistortion or saved file
[ "lens", "-", ">", "instance", "of", "LensDistortion", "or", "saved", "file" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L269-L285
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.clearOldCalibrations
def clearOldCalibrations(self, date=None): ''' if not only a specific date than remove all except of the youngest calibration ''' self.coeffs['dark current'] = [self.coeffs['dark current'][-1]] self.coeffs['noise'] = [self.coeffs['noise'][-1]] for light in self.co...
python
def clearOldCalibrations(self, date=None): ''' if not only a specific date than remove all except of the youngest calibration ''' self.coeffs['dark current'] = [self.coeffs['dark current'][-1]] self.coeffs['noise'] = [self.coeffs['noise'][-1]] for light in self.co...
[ "def", "clearOldCalibrations", "(", "self", ",", "date", "=", "None", ")", ":", "self", ".", "coeffs", "[", "'dark current'", "]", "=", "[", "self", ".", "coeffs", "[", "'dark current'", "]", "[", "-", "1", "]", "]", "self", ".", "coeffs", "[", "'noi...
if not only a specific date than remove all except of the youngest calibration
[ "if", "not", "only", "a", "specific", "date", "than", "remove", "all", "except", "of", "the", "youngest", "calibration" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L287-L298
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.transpose
def transpose(self): ''' transpose all calibration arrays in case different array shape orders were used (x,y) vs. (y,x) ''' def _t(item): if type(item) == list: for n, it in enumerate(item): if type(it) == tuple: ...
python
def transpose(self): ''' transpose all calibration arrays in case different array shape orders were used (x,y) vs. (y,x) ''' def _t(item): if type(item) == list: for n, it in enumerate(item): if type(it) == tuple: ...
[ "def", "transpose", "(", "self", ")", ":", "def", "_t", "(", "item", ")", ":", "if", "type", "(", "item", ")", "==", "list", ":", "for", "n", ",", "it", "in", "enumerate", "(", "item", ")", ":", "if", "type", "(", "it", ")", "==", "tuple", ":...
transpose all calibration arrays in case different array shape orders were used (x,y) vs. (y,x)
[ "transpose", "all", "calibration", "arrays", "in", "case", "different", "array", "shape", "orders", "were", "used", "(", "x", "y", ")", "vs", ".", "(", "y", "x", ")" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L324-L349
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.correct
def correct(self, images, bgImages=None, exposure_time=None, light_spectrum=None, threshold=0.1, keep_size=True, date=None, deblur=False, denoise=False): ''' exposure...
python
def correct(self, images, bgImages=None, exposure_time=None, light_spectrum=None, threshold=0.1, keep_size=True, date=None, deblur=False, denoise=False): ''' exposure...
[ "def", "correct", "(", "self", ",", "images", ",", "bgImages", "=", "None", ",", "exposure_time", "=", "None", ",", "light_spectrum", "=", "None", ",", "threshold", "=", "0.1", ",", "keep_size", "=", "True", ",", "date", "=", "None", ",", "deblur", "="...
exposure_time [s] date -> string e.g. '30. Nov 15' to get a calibration on from date -> {'dark current':'30. Nov 15', 'flat field':'15. Nov 15', 'lens':'14. Nov 15', 'noise':'01. Nov 15'}
[ "exposure_time", "[", "s", "]", "date", "-", ">", "string", "e", ".", "g", ".", "30", ".", "Nov", "15", "to", "get", "a", "calibration", "on", "from", "date", "-", ">", "{", "dark", "current", ":", "30", ".", "Nov", "15", "flat", "field", ":", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L351-L459
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration._correctNoise
def _correctNoise(self, image): ''' denoise using non-local-means with guessing best parameters ''' from skimage.restoration import denoise_nl_means # save startup time image[np.isnan(image)] = 0 # otherwise result =nan out = denoise_nl_means(image, ...
python
def _correctNoise(self, image): ''' denoise using non-local-means with guessing best parameters ''' from skimage.restoration import denoise_nl_means # save startup time image[np.isnan(image)] = 0 # otherwise result =nan out = denoise_nl_means(image, ...
[ "def", "_correctNoise", "(", "self", ",", "image", ")", ":", "from", "skimage", ".", "restoration", "import", "denoise_nl_means", "# save startup time\r", "image", "[", "np", ".", "isnan", "(", "image", ")", "]", "=", "0", "# otherwise result =nan\r", "out", "...
denoise using non-local-means with guessing best parameters
[ "denoise", "using", "non", "-", "local", "-", "means", "with", "guessing", "best", "parameters" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L461-L474
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration._correctDarkCurrent
def _correctDarkCurrent(self, image, exposuretime, bgImages, date): ''' open OR calculate a background image: f(t)=m*t+n ''' # either exposureTime or bgImages has to be given # if exposuretime is not None or bgImages is not None: print('... remove dark current') ...
python
def _correctDarkCurrent(self, image, exposuretime, bgImages, date): ''' open OR calculate a background image: f(t)=m*t+n ''' # either exposureTime or bgImages has to be given # if exposuretime is not None or bgImages is not None: print('... remove dark current') ...
[ "def", "_correctDarkCurrent", "(", "self", ",", "image", ",", "exposuretime", ",", "bgImages", ",", "date", ")", ":", "# either exposureTime or bgImages has to be given\r", "# if exposuretime is not None or bgImages is not None:\r", "print", "(", "'... remove dark current...
open OR calculate a background image: f(t)=m*t+n
[ "open", "OR", "calculate", "a", "background", "image", ":", "f", "(", "t", ")", "=", "m", "*", "t", "+", "n" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L476-L502
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration._correctArtefacts
def _correctArtefacts(self, image, threshold): ''' Apply a thresholded median replacing high gradients and values beyond the boundaries ''' image = np.nan_to_num(image) medianThreshold(image, threshold, copy=False) return image
python
def _correctArtefacts(self, image, threshold): ''' Apply a thresholded median replacing high gradients and values beyond the boundaries ''' image = np.nan_to_num(image) medianThreshold(image, threshold, copy=False) return image
[ "def", "_correctArtefacts", "(", "self", ",", "image", ",", "threshold", ")", ":", "image", "=", "np", ".", "nan_to_num", "(", "image", ")", "medianThreshold", "(", "image", ",", "threshold", ",", "copy", "=", "False", ")", "return", "image" ]
Apply a thresholded median replacing high gradients and values beyond the boundaries
[ "Apply", "a", "thresholded", "median", "replacing", "high", "gradients", "and", "values", "beyond", "the", "boundaries" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L556-L563
radjkarl/imgProcessor
imgProcessor/camera/CameraCalibration.py
CameraCalibration.getCoeff
def getCoeff(self, name, light=None, date=None): ''' try to get calibration for right light source, but use another if they is none existent ''' d = self.coeffs[name] try: c = d[light] except KeyError: try: k, i ...
python
def getCoeff(self, name, light=None, date=None): ''' try to get calibration for right light source, but use another if they is none existent ''' d = self.coeffs[name] try: c = d[light] except KeyError: try: k, i ...
[ "def", "getCoeff", "(", "self", ",", "name", ",", "light", "=", "None", ",", "date", "=", "None", ")", ":", "d", "=", "self", ".", "coeffs", "[", "name", "]", "try", ":", "c", "=", "d", "[", "light", "]", "except", "KeyError", ":", "try", ":", ...
try to get calibration for right light source, but use another if they is none existent
[ "try", "to", "get", "calibration", "for", "right", "light", "source", "but", "use", "another", "if", "they", "is", "none", "existent" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L590-L611
radjkarl/imgProcessor
imgProcessor/camera/flatField/vignettingFromRandomSteps.py
vignettingFromRandomSteps
def vignettingFromRandomSteps(imgs, bg, inPlane_scale_factor=None, debugFolder=None, **kwargs): ''' important: first image should shown most iof the device because it is used as reference ''' # TODO: inPlane_scale_factor if debugFolder: debugFolder =...
python
def vignettingFromRandomSteps(imgs, bg, inPlane_scale_factor=None, debugFolder=None, **kwargs): ''' important: first image should shown most iof the device because it is used as reference ''' # TODO: inPlane_scale_factor if debugFolder: debugFolder =...
[ "def", "vignettingFromRandomSteps", "(", "imgs", ",", "bg", ",", "inPlane_scale_factor", "=", "None", ",", "debugFolder", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# TODO: inPlane_scale_factor\r", "if", "debugFolder", ":", "debugFolder", "=", "PathStr", "...
important: first image should shown most iof the device because it is used as reference
[ "important", ":", "first", "image", "should", "shown", "most", "iof", "the", "device", "because", "it", "is", "used", "as", "reference" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L324-L352
radjkarl/imgProcessor
imgProcessor/camera/flatField/vignettingFromRandomSteps.py
ObjectVignettingSeparation.addImg
def addImg(self, img, maxShear=0.015, maxRot=100, minMatches=12, borderWidth=3): # borderWidth=100 """ Args: img (path or array): image containing the same object as in the reference image Kwargs: maxShear (float): In order to define a good fit, refe...
python
def addImg(self, img, maxShear=0.015, maxRot=100, minMatches=12, borderWidth=3): # borderWidth=100 """ Args: img (path or array): image containing the same object as in the reference image Kwargs: maxShear (float): In order to define a good fit, refe...
[ "def", "addImg", "(", "self", ",", "img", ",", "maxShear", "=", "0.015", ",", "maxRot", "=", "100", ",", "minMatches", "=", "12", ",", "borderWidth", "=", "3", ")", ":", "# borderWidth=100\r", "try", ":", "fit", ",", "img", ",", "H", ",", "H_inv", ...
Args: img (path or array): image containing the same object as in the reference image Kwargs: maxShear (float): In order to define a good fit, refect higher shear values between this and the reference image maxRot (float): Same for rotation ...
[ "Args", ":", "img", "(", "path", "or", "array", ")", ":", "image", "containing", "the", "same", "object", "as", "in", "the", "reference", "image", "Kwargs", ":", "maxShear", "(", "float", ")", ":", "In", "order", "to", "define", "a", "good", "fit", "...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L114-L167
radjkarl/imgProcessor
imgProcessor/camera/flatField/vignettingFromRandomSteps.py
ObjectVignettingSeparation.error
def error(self, nCells=15): ''' calculate the standard deviation of all fitted images, averaged to a grid ''' s0, s1 = self.fits[0].shape aR = s0 / s1 if aR > 1: ss0 = int(nCells) ss1 = int(ss0 / aR) else: ss...
python
def error(self, nCells=15): ''' calculate the standard deviation of all fitted images, averaged to a grid ''' s0, s1 = self.fits[0].shape aR = s0 / s1 if aR > 1: ss0 = int(nCells) ss1 = int(ss0 / aR) else: ss...
[ "def", "error", "(", "self", ",", "nCells", "=", "15", ")", ":", "s0", ",", "s1", "=", "self", ".", "fits", "[", "0", "]", ".", "shape", "aR", "=", "s0", "/", "s1", "if", "aR", ">", "1", ":", "ss0", "=", "int", "(", "nCells", ")", "ss1", ...
calculate the standard deviation of all fitted images, averaged to a grid
[ "calculate", "the", "standard", "deviation", "of", "all", "fitted", "images", "averaged", "to", "a", "grid" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L169-L197
radjkarl/imgProcessor
imgProcessor/camera/flatField/vignettingFromRandomSteps.py
ObjectVignettingSeparation._fitImg
def _fitImg(self, img): ''' fit perspective and size of the input image to the reference image ''' img = imread(img, 'gray') if self.bg is not None: img = cv2.subtract(img, self.bg) if self.lens is not None: img = self.lens.correct(img, k...
python
def _fitImg(self, img): ''' fit perspective and size of the input image to the reference image ''' img = imread(img, 'gray') if self.bg is not None: img = cv2.subtract(img, self.bg) if self.lens is not None: img = self.lens.correct(img, k...
[ "def", "_fitImg", "(", "self", ",", "img", ")", ":", "img", "=", "imread", "(", "img", ",", "'gray'", ")", "if", "self", ".", "bg", "is", "not", "None", ":", "img", "=", "cv2", ".", "subtract", "(", "img", ",", "self", ".", "bg", ")", "if", "...
fit perspective and size of the input image to the reference image
[ "fit", "perspective", "and", "size", "of", "the", "input", "image", "to", "the", "reference", "image" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L294-L310
radjkarl/imgProcessor
imgProcessor/camera/flatField/vignettingFromRandomSteps.py
ObjectVignettingSeparation._findObject
def _findObject(self, img): ''' Create a bounding box around the object within an image ''' from imgProcessor.imgSignal import signalMinimum # img is scaled already i = img > signalMinimum(img) # img.max()/2.5 # filter noise, single-time-effects etc. from ...
python
def _findObject(self, img): ''' Create a bounding box around the object within an image ''' from imgProcessor.imgSignal import signalMinimum # img is scaled already i = img > signalMinimum(img) # img.max()/2.5 # filter noise, single-time-effects etc. from ...
[ "def", "_findObject", "(", "self", ",", "img", ")", ":", "from", "imgProcessor", ".", "imgSignal", "import", "signalMinimum", "# img is scaled already\r", "i", "=", "img", ">", "signalMinimum", "(", "img", ")", "# img.max()/2.5\r", "# filter noise, single-time-effects...
Create a bounding box around the object within an image
[ "Create", "a", "bounding", "box", "around", "the", "object", "within", "an", "image" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L312-L321
radjkarl/imgProcessor
imgProcessor/filters/filterVerticalLines.py
filterVerticalLines
def filterVerticalLines(arr, min_line_length=4): """ Remove vertical lines in boolean array if linelength >=min_line_length """ gy = arr.shape[0] gx = arr.shape[1] mn = min_line_length-1 for i in range(gy): for j in range(gx): if arr[i,j]: for d ...
python
def filterVerticalLines(arr, min_line_length=4): """ Remove vertical lines in boolean array if linelength >=min_line_length """ gy = arr.shape[0] gx = arr.shape[1] mn = min_line_length-1 for i in range(gy): for j in range(gx): if arr[i,j]: for d ...
[ "def", "filterVerticalLines", "(", "arr", ",", "min_line_length", "=", "4", ")", ":", "gy", "=", "arr", ".", "shape", "[", "0", "]", "gx", "=", "arr", ".", "shape", "[", "1", "]", "mn", "=", "min_line_length", "-", "1", "for", "i", "in", "range", ...
Remove vertical lines in boolean array if linelength >=min_line_length
[ "Remove", "vertical", "lines", "in", "boolean", "array", "if", "linelength", ">", "=", "min_line_length" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/filterVerticalLines.py#L4-L23
radjkarl/imgProcessor
imgProcessor/equations/vignetting.py
vignetting
def vignetting(xy, f=100, alpha=0, rot=0, tilt=0, cx=50, cy=50): ''' Vignetting equation using the KANG-WEISS-MODEL see http://research.microsoft.com/en-us/um/people/sbkang/publications/eccv00.pdf f - focal length alpha - coefficient in the geometric vignetting factor tilt - tilt angl...
python
def vignetting(xy, f=100, alpha=0, rot=0, tilt=0, cx=50, cy=50): ''' Vignetting equation using the KANG-WEISS-MODEL see http://research.microsoft.com/en-us/um/people/sbkang/publications/eccv00.pdf f - focal length alpha - coefficient in the geometric vignetting factor tilt - tilt angl...
[ "def", "vignetting", "(", "xy", ",", "f", "=", "100", ",", "alpha", "=", "0", ",", "rot", "=", "0", ",", "tilt", "=", "0", ",", "cx", "=", "50", ",", "cy", "=", "50", ")", ":", "x", ",", "y", "=", "xy", "# distance to image center:\r", "dist", ...
Vignetting equation using the KANG-WEISS-MODEL see http://research.microsoft.com/en-us/um/people/sbkang/publications/eccv00.pdf f - focal length alpha - coefficient in the geometric vignetting factor tilt - tilt angle of a planar scene rot - rotation angle of a planar scene cx - image...
[ "Vignetting", "equation", "using", "the", "KANG", "-", "WEISS", "-", "MODEL", "see", "http", ":", "//", "research", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "um", "/", "people", "/", "sbkang", "/", "publications", "/", "eccv00", ".", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/vignetting.py#L9-L37
radjkarl/imgProcessor
imgProcessor/equations/vignetting.py
tiltFactor
def tiltFactor(xy, f, tilt, rot, center=None): ''' this function is extra to only cover vignetting through perspective distortion f - focal length [px] tau - tilt angle of a planar scene [radian] rot - rotation angle of a planar scene [radian] ''' x, y = xy arr = np.cos(tilt) *...
python
def tiltFactor(xy, f, tilt, rot, center=None): ''' this function is extra to only cover vignetting through perspective distortion f - focal length [px] tau - tilt angle of a planar scene [radian] rot - rotation angle of a planar scene [radian] ''' x, y = xy arr = np.cos(tilt) *...
[ "def", "tiltFactor", "(", "xy", ",", "f", ",", "tilt", ",", "rot", ",", "center", "=", "None", ")", ":", "x", ",", "y", "=", "xy", "arr", "=", "np", ".", "cos", "(", "tilt", ")", "*", "(", "1", "+", "(", "np", ".", "tan", "(", "tilt", ")"...
this function is extra to only cover vignetting through perspective distortion f - focal length [px] tau - tilt angle of a planar scene [radian] rot - rotation angle of a planar scene [radian]
[ "this", "function", "is", "extra", "to", "only", "cover", "vignetting", "through", "perspective", "distortion", "f", "-", "focal", "length", "[", "px", "]", "tau", "-", "tilt", "angle", "of", "a", "planar", "scene", "[", "radian", "]", "rot", "-", "rotat...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/vignetting.py#L40-L52
radjkarl/imgProcessor
imgProcessor/transform/imgAverage.py
imgAverage
def imgAverage(images, copy=True): ''' returns an image average works on many, also unloaded images minimises RAM usage ''' i0 = images[0] out = imread(i0, dtype='float') if copy and id(i0) == id(out): out = out.copy() for i in images[1:]: out += imread...
python
def imgAverage(images, copy=True): ''' returns an image average works on many, also unloaded images minimises RAM usage ''' i0 = images[0] out = imread(i0, dtype='float') if copy and id(i0) == id(out): out = out.copy() for i in images[1:]: out += imread...
[ "def", "imgAverage", "(", "images", ",", "copy", "=", "True", ")", ":", "i0", "=", "images", "[", "0", "]", "out", "=", "imread", "(", "i0", ",", "dtype", "=", "'float'", ")", "if", "copy", "and", "id", "(", "i0", ")", "==", "id", "(", "out", ...
returns an image average works on many, also unloaded images minimises RAM usage
[ "returns", "an", "image", "average", "works", "on", "many", "also", "unloaded", "images", "minimises", "RAM", "usage" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/imgAverage.py#L7-L22
radjkarl/imgProcessor
imgProcessor/interpolate/offsetMeshgrid.py
offsetMeshgrid
def offsetMeshgrid(offset, grid, shape): ''' Imagine you have cell averages [grid] on an image. the top-left position of [grid] within the image can be variable [offset] offset(x,y) e.g.(0,0) if no offset grid(nx,ny) resolution of smaller grid shape(x,y) -> output sha...
python
def offsetMeshgrid(offset, grid, shape): ''' Imagine you have cell averages [grid] on an image. the top-left position of [grid] within the image can be variable [offset] offset(x,y) e.g.(0,0) if no offset grid(nx,ny) resolution of smaller grid shape(x,y) -> output sha...
[ "def", "offsetMeshgrid", "(", "offset", ",", "grid", ",", "shape", ")", ":", "g0", ",", "g1", "=", "grid", "s0", ",", "s1", "=", "shape", "o0", ",", "o1", "=", "offset", "#rescale to small grid:\r", "o0", "=", "-", "o0", "/", "s0", "*", "(", "g0", ...
Imagine you have cell averages [grid] on an image. the top-left position of [grid] within the image can be variable [offset] offset(x,y) e.g.(0,0) if no offset grid(nx,ny) resolution of smaller grid shape(x,y) -> output shape returns meshgrid to be used to upscale [...
[ "Imagine", "you", "have", "cell", "averages", "[", "grid", "]", "on", "an", "image", ".", "the", "top", "-", "left", "position", "of", "[", "grid", "]", "within", "the", "image", "can", "be", "variable", "[", "offset", "]", "offset", "(", "x", "y", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/offsetMeshgrid.py#L5-L27
radjkarl/imgProcessor
imgProcessor/equations/poisson.py
poisson
def poisson(x, a, b, c, d=0): ''' Poisson function a -> height of the curve's peak b -> position of the center of the peak c -> standard deviation d -> offset ''' from scipy.misc import factorial #save startup time lamb = 1 X = (x/(2*c)).astype(int) return a * ((...
python
def poisson(x, a, b, c, d=0): ''' Poisson function a -> height of the curve's peak b -> position of the center of the peak c -> standard deviation d -> offset ''' from scipy.misc import factorial #save startup time lamb = 1 X = (x/(2*c)).astype(int) return a * ((...
[ "def", "poisson", "(", "x", ",", "a", ",", "b", ",", "c", ",", "d", "=", "0", ")", ":", "from", "scipy", ".", "misc", "import", "factorial", "#save startup time\r", "lamb", "=", "1", "X", "=", "(", "x", "/", "(", "2", "*", "c", ")", ")", ".",...
Poisson function a -> height of the curve's peak b -> position of the center of the peak c -> standard deviation d -> offset
[ "Poisson", "function", "a", "-", ">", "height", "of", "the", "curve", "s", "peak", "b", "-", ">", "position", "of", "the", "center", "of", "the", "peak", "c", "-", ">", "standard", "deviation", "d", "-", ">", "offset" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/poisson.py#L4-L15
radjkarl/imgProcessor
imgProcessor/transform/rotate.py
rotate
def rotate(image, angle, interpolation=cv2.INTER_CUBIC, borderMode=cv2.BORDER_REFLECT, borderValue=0): ''' angle [deg] ''' s0, s1 = image.shape image_center = (s0 - 1) / 2., (s1 - 1) / 2. rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1.0) result = cv2.warpAffine(i...
python
def rotate(image, angle, interpolation=cv2.INTER_CUBIC, borderMode=cv2.BORDER_REFLECT, borderValue=0): ''' angle [deg] ''' s0, s1 = image.shape image_center = (s0 - 1) / 2., (s1 - 1) / 2. rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1.0) result = cv2.warpAffine(i...
[ "def", "rotate", "(", "image", ",", "angle", ",", "interpolation", "=", "cv2", ".", "INTER_CUBIC", ",", "borderMode", "=", "cv2", ".", "BORDER_REFLECT", ",", "borderValue", "=", "0", ")", ":", "s0", ",", "s1", "=", "image", ".", "shape", "image_center", ...
angle [deg]
[ "angle", "[", "deg", "]" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/rotate.py#L8-L19
radjkarl/imgProcessor
imgProcessor/uncertainty/adjustUncertToExposureTime.py
adjustUncertToExposureTime
def adjustUncertToExposureTime(facExpTime, uncertMap, evtLenMap): ''' Adjust image uncertainty (measured at exposure time t0) to new exposure time facExpTime --> new exp.time / reference exp.time =(t/t0) uncertMap --> 2d array mapping image uncertainty evtLen --> 2d array mappi...
python
def adjustUncertToExposureTime(facExpTime, uncertMap, evtLenMap): ''' Adjust image uncertainty (measured at exposure time t0) to new exposure time facExpTime --> new exp.time / reference exp.time =(t/t0) uncertMap --> 2d array mapping image uncertainty evtLen --> 2d array mappi...
[ "def", "adjustUncertToExposureTime", "(", "facExpTime", ",", "uncertMap", ",", "evtLenMap", ")", ":", "#fit parameters, obtained from ####[simulateUncertDependencyOnExpTime]\r", "params", "=", "np", ".", "array", "(", "#a facExpTime f_0 f_inf ...
Adjust image uncertainty (measured at exposure time t0) to new exposure time facExpTime --> new exp.time / reference exp.time =(t/t0) uncertMap --> 2d array mapping image uncertainty evtLen --> 2d array mapping event duration within image [sec] event duration is relative...
[ "Adjust", "image", "uncertainty", "(", "measured", "at", "exposure", "time", "t0", ")", "to", "new", "exposure", "time", "facExpTime", "--", ">", "new", "exp", ".", "time", "/", "reference", "exp", ".", "time", "=", "(", "t", "/", "t0", ")", "uncertMap...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/adjustUncertToExposureTime.py#L10-L59
radjkarl/imgProcessor
imgProcessor/equations/gaussian.py
gaussian
def gaussian(x, a, b, c, d=0): ''' a -> height of the curve's peak b -> position of the center of the peak c -> standard deviation or Gaussian RMS width d -> offset ''' return a * np.exp( -(((x-b)**2 )/ (2*(c**2))) ) + d
python
def gaussian(x, a, b, c, d=0): ''' a -> height of the curve's peak b -> position of the center of the peak c -> standard deviation or Gaussian RMS width d -> offset ''' return a * np.exp( -(((x-b)**2 )/ (2*(c**2))) ) + d
[ "def", "gaussian", "(", "x", ",", "a", ",", "b", ",", "c", ",", "d", "=", "0", ")", ":", "return", "a", "*", "np", ".", "exp", "(", "-", "(", "(", "(", "x", "-", "b", ")", "**", "2", ")", "/", "(", "2", "*", "(", "c", "**", "2", ")"...
a -> height of the curve's peak b -> position of the center of the peak c -> standard deviation or Gaussian RMS width d -> offset
[ "a", "-", ">", "height", "of", "the", "curve", "s", "peak", "b", "-", ">", "position", "of", "the", "center", "of", "the", "peak", "c", "-", ">", "standard", "deviation", "or", "Gaussian", "RMS", "width", "d", "-", ">", "offset" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/gaussian.py#L6-L13
radjkarl/imgProcessor
imgProcessor/interpolate/videoWrite.py
videoWrite
def videoWrite(path, imgs, levels=None, shape=None, frames=15, annotate_names=None, lut=None, updateFn=None): ''' TODO ''' frames = int(frames) if annotate_names is not None: assert len(annotate_names) == len(imgs) if levels is None: if i...
python
def videoWrite(path, imgs, levels=None, shape=None, frames=15, annotate_names=None, lut=None, updateFn=None): ''' TODO ''' frames = int(frames) if annotate_names is not None: assert len(annotate_names) == len(imgs) if levels is None: if i...
[ "def", "videoWrite", "(", "path", ",", "imgs", ",", "levels", "=", "None", ",", "shape", "=", "None", ",", "frames", "=", "15", ",", "annotate_names", "=", "None", ",", "lut", "=", "None", ",", "updateFn", "=", "None", ")", ":", "frames", "=", "int...
TODO
[ "TODO" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/videoWrite.py#L14-L81
radjkarl/imgProcessor
imgProcessor/imgIO.py
imread
def imread(img, color=None, dtype=None): ''' dtype = 'noUint', uint8, float, 'float', ... ''' COLOR2CV = {'gray': cv2.IMREAD_GRAYSCALE, 'all': cv2.IMREAD_COLOR, None: cv2.IMREAD_ANYCOLOR } c = COLOR2CV[color] if callable(img): img...
python
def imread(img, color=None, dtype=None): ''' dtype = 'noUint', uint8, float, 'float', ... ''' COLOR2CV = {'gray': cv2.IMREAD_GRAYSCALE, 'all': cv2.IMREAD_COLOR, None: cv2.IMREAD_ANYCOLOR } c = COLOR2CV[color] if callable(img): img...
[ "def", "imread", "(", "img", ",", "color", "=", "None", ",", "dtype", "=", "None", ")", ":", "COLOR2CV", "=", "{", "'gray'", ":", "cv2", ".", "IMREAD_GRAYSCALE", ",", "'all'", ":", "cv2", ".", "IMREAD_COLOR", ",", "None", ":", "cv2", ".", "IMREAD_ANY...
dtype = 'noUint', uint8, float, 'float', ...
[ "dtype", "=", "noUint", "uint8", "float", "float", "..." ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgIO.py#L39-L73
radjkarl/imgProcessor
imgProcessor/measure/sharpness/SharpnessfromPoints.py
SharpnessfromPointSources.addImg
def addImg(self, img, roi=None): ''' img - background, flat field, ste corrected image roi - [(x1,y1),...,(x4,y4)] - boundaries where points are ''' self.img = imread(img, 'gray') s0, s1 = self.img.shape if roi is None: roi = ((0, 0), (s0, 0...
python
def addImg(self, img, roi=None): ''' img - background, flat field, ste corrected image roi - [(x1,y1),...,(x4,y4)] - boundaries where points are ''' self.img = imread(img, 'gray') s0, s1 = self.img.shape if roi is None: roi = ((0, 0), (s0, 0...
[ "def", "addImg", "(", "self", ",", "img", ",", "roi", "=", "None", ")", ":", "self", ".", "img", "=", "imread", "(", "img", ",", "'gray'", ")", "s0", ",", "s1", "=", "self", ".", "img", ".", "shape", "if", "roi", "is", "None", ":", "roi", "="...
img - background, flat field, ste corrected image roi - [(x1,y1),...,(x4,y4)] - boundaries where points are
[ "img", "-", "background", "flat", "field", "ste", "corrected", "image", "roi", "-", "[", "(", "x1", "y1", ")", "...", "(", "x4", "y4", ")", "]", "-", "boundaries", "where", "points", "are" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/SharpnessfromPoints.py#L78-L220
radjkarl/imgProcessor
imgProcessor/interpolate/interpolate2dStructuredFastIDW.py
interpolate2dStructuredFastIDW
def interpolate2dStructuredFastIDW(grid, mask, kernel=15, power=2, minnvals=5): ''' FASTER IMPLEMENTATION OF interpolate2dStructuredIDW replace all values in [grid] indicated by [mask] with the inverse distance weighted interpolation of all values within px...
python
def interpolate2dStructuredFastIDW(grid, mask, kernel=15, power=2, minnvals=5): ''' FASTER IMPLEMENTATION OF interpolate2dStructuredIDW replace all values in [grid] indicated by [mask] with the inverse distance weighted interpolation of all values within px...
[ "def", "interpolate2dStructuredFastIDW", "(", "grid", ",", "mask", ",", "kernel", "=", "15", ",", "power", "=", "2", ",", "minnvals", "=", "5", ")", ":", "indices", ",", "dist", "=", "growPositions", "(", "kernel", ")", "weights", "=", "1", "/", "dist"...
FASTER IMPLEMENTATION OF interpolate2dStructuredIDW replace all values in [grid] indicated by [mask] with the inverse distance weighted interpolation of all values within px+-kernel [power] -> distance weighting factor: 1/distance**[power] [minvals] -> minimum number of neighbour values to ...
[ "FASTER", "IMPLEMENTATION", "OF", "interpolate2dStructuredIDW", "replace", "all", "values", "in", "[", "grid", "]", "indicated", "by", "[", "mask", "]", "with", "the", "inverse", "distance", "weighted", "interpolation", "of", "all", "values", "within", "px", "+"...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredFastIDW.py#L9-L26
radjkarl/imgProcessor
imgProcessor/transform/linearBlend.py
linearBlend
def linearBlend(img1, img2, overlap, backgroundColor=None): ''' Stitch 2 images vertically together. Smooth the overlap area of both images with a linear fade from img1 to img2 @param img1: numpy.2dArray @param img2: numpy.2dArray of the same shape[1,2] as img1 @param overlap: number of ...
python
def linearBlend(img1, img2, overlap, backgroundColor=None): ''' Stitch 2 images vertically together. Smooth the overlap area of both images with a linear fade from img1 to img2 @param img1: numpy.2dArray @param img2: numpy.2dArray of the same shape[1,2] as img1 @param overlap: number of ...
[ "def", "linearBlend", "(", "img1", ",", "img2", ",", "overlap", ",", "backgroundColor", "=", "None", ")", ":", "(", "sizex", ",", "sizey", ")", "=", "img1", ".", "shape", "[", ":", "2", "]", "overlapping", "=", "True", "if", "overlap", "<", "0", ":...
Stitch 2 images vertically together. Smooth the overlap area of both images with a linear fade from img1 to img2 @param img1: numpy.2dArray @param img2: numpy.2dArray of the same shape[1,2] as img1 @param overlap: number of pixels both images overlap @returns: stitched-image
[ "Stitch", "2", "images", "vertically", "together", ".", "Smooth", "the", "overlap", "area", "of", "both", "images", "with", "a", "linear", "fade", "from", "img1", "to", "img2" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/linearBlend.py#L7-L55
radjkarl/imgProcessor
imgProcessor/interpolate/interpolate2dStructuredPointSpreadIDW.py
interpolate2dStructuredPointSpreadIDW
def interpolate2dStructuredPointSpreadIDW(grid, mask, kernel=15, power=2, maxIter=1e5, copy=True): ''' same as interpolate2dStructuredIDW but using the point spread method this is faster if there are bigger connected masked areas and the border length is sm...
python
def interpolate2dStructuredPointSpreadIDW(grid, mask, kernel=15, power=2, maxIter=1e5, copy=True): ''' same as interpolate2dStructuredIDW but using the point spread method this is faster if there are bigger connected masked areas and the border length is sm...
[ "def", "interpolate2dStructuredPointSpreadIDW", "(", "grid", ",", "mask", ",", "kernel", "=", "15", ",", "power", "=", "2", ",", "maxIter", "=", "1e5", ",", "copy", "=", "True", ")", ":", "assert", "grid", ".", "shape", "==", "mask", ".", "shape", ",",...
same as interpolate2dStructuredIDW but using the point spread method this is faster if there are bigger connected masked areas and the border length is smaller replace all values in [grid] indicated by [mask] with the inverse distance weighted interpolation of all values within px+-kernel ...
[ "same", "as", "interpolate2dStructuredIDW", "but", "using", "the", "point", "spread", "method", "this", "is", "faster", "if", "there", "are", "bigger", "connected", "masked", "areas", "and", "the", "border", "length", "is", "smaller", "replace", "all", "values",...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredPointSpreadIDW.py#L7-L28
radjkarl/imgProcessor
imgProcessor/measure/SNR/SNRaverage.py
SNRaverage
def SNRaverage(snr, method='average', excludeBackground=True, checkBackground=True, backgroundLevel=None): ''' average a signal-to-noise map :param method: ['average','X75', 'RMS', 'median'] - X75: this SNR will be exceeded by 75% of the signal :type method: str ...
python
def SNRaverage(snr, method='average', excludeBackground=True, checkBackground=True, backgroundLevel=None): ''' average a signal-to-noise map :param method: ['average','X75', 'RMS', 'median'] - X75: this SNR will be exceeded by 75% of the signal :type method: str ...
[ "def", "SNRaverage", "(", "snr", ",", "method", "=", "'average'", ",", "excludeBackground", "=", "True", ",", "checkBackground", "=", "True", ",", "backgroundLevel", "=", "None", ")", ":", "if", "excludeBackground", ":", "# get background level\r", "if", "backgr...
average a signal-to-noise map :param method: ['average','X75', 'RMS', 'median'] - X75: this SNR will be exceeded by 75% of the signal :type method: str :param checkBackground: check whether there is actually a background level to exclude :type checkBackground: bool :returns: averaged SNR as ...
[ "average", "a", "signal", "-", "to", "-", "noise", "map", ":", "param", "method", ":", "[", "average", "X75", "RMS", "median", "]", "-", "X75", ":", "this", "SNR", "will", "be", "exceeded", "by", "75%", "of", "the", "signal", ":", "type", "method", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNRaverage.py#L10-L58
radjkarl/imgProcessor
imgProcessor/filters/maskedConvolve.py
maskedConvolve
def maskedConvolve(arr, kernel, mask, mode='reflect'): ''' same as scipy.ndimage.convolve but is only executed on mask==True ... which should speed up everything ''' arr2 = extendArrayForConvolution(arr, kernel.shape, modex=mode, modey=mode) print(arr2.shape) out = np.zeros_like(arr) ...
python
def maskedConvolve(arr, kernel, mask, mode='reflect'): ''' same as scipy.ndimage.convolve but is only executed on mask==True ... which should speed up everything ''' arr2 = extendArrayForConvolution(arr, kernel.shape, modex=mode, modey=mode) print(arr2.shape) out = np.zeros_like(arr) ...
[ "def", "maskedConvolve", "(", "arr", ",", "kernel", ",", "mask", ",", "mode", "=", "'reflect'", ")", ":", "arr2", "=", "extendArrayForConvolution", "(", "arr", ",", "kernel", ".", "shape", ",", "modex", "=", "mode", ",", "modey", "=", "mode", ")", "pri...
same as scipy.ndimage.convolve but is only executed on mask==True ... which should speed up everything
[ "same", "as", "scipy", ".", "ndimage", ".", "convolve", "but", "is", "only", "executed", "on", "mask", "==", "True", "...", "which", "should", "speed", "up", "everything" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/maskedConvolve.py#L13-L21
radjkarl/imgProcessor
imgProcessor/measure/SNR/SNR.py
SNR
def SNR(img1, img2=None, bg=None, noise_level_function=None, constant_noise_level=False, imgs_to_be_averaged=False): ''' Returns a signal-to-noise-map uses algorithm as described in BEDRICH 2016 JPV (not jet published) :param constant_noise_level: True, to assume noise t...
python
def SNR(img1, img2=None, bg=None, noise_level_function=None, constant_noise_level=False, imgs_to_be_averaged=False): ''' Returns a signal-to-noise-map uses algorithm as described in BEDRICH 2016 JPV (not jet published) :param constant_noise_level: True, to assume noise t...
[ "def", "SNR", "(", "img1", ",", "img2", "=", "None", ",", "bg", "=", "None", ",", "noise_level_function", "=", "None", ",", "constant_noise_level", "=", "False", ",", "imgs_to_be_averaged", "=", "False", ")", ":", "# dark current subtraction:\r", "img1", "=", ...
Returns a signal-to-noise-map uses algorithm as described in BEDRICH 2016 JPV (not jet published) :param constant_noise_level: True, to assume noise to be constant :param imgs_to_be_averaged: True, if SNR is for average(img1, img2)
[ "Returns", "a", "signal", "-", "to", "-", "noise", "-", "map", "uses", "algorithm", "as", "described", "in", "BEDRICH", "2016", "JPV", "(", "not", "jet", "published", ")", ":", "param", "constant_noise_level", ":", "True", "to", "assume", "noise", "to", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNR.py#L21-L79
radjkarl/imgProcessor
imgProcessor/utils/sortCorners.py
sortCorners
def sortCorners(corners): ''' sort the corners of a given quadrilateral of the type corners : [ [xi,yi],... ] to an anti-clockwise order starting with the bottom left corner or (if plotted as image where y increases to the bottom): clockwise, starting top left ''' corners = n...
python
def sortCorners(corners): ''' sort the corners of a given quadrilateral of the type corners : [ [xi,yi],... ] to an anti-clockwise order starting with the bottom left corner or (if plotted as image where y increases to the bottom): clockwise, starting top left ''' corners = n...
[ "def", "sortCorners", "(", "corners", ")", ":", "corners", "=", "np", ".", "asarray", "(", "corners", ")", "# bring edges in order:\r", "corners2", "=", "corners", "[", "ConvexHull", "(", "corners", ")", ".", "vertices", "]", "if", "len", "(", "corners2", ...
sort the corners of a given quadrilateral of the type corners : [ [xi,yi],... ] to an anti-clockwise order starting with the bottom left corner or (if plotted as image where y increases to the bottom): clockwise, starting top left
[ "sort", "the", "corners", "of", "a", "given", "quadrilateral", "of", "the", "type", "corners", ":", "[", "[", "xi", "yi", "]", "...", "]", "to", "an", "anti", "-", "clockwise", "order", "starting", "with", "the", "bottom", "left", "corner", "or", "(", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/sortCorners.py#L8-L50
radjkarl/imgProcessor
imgProcessor/render/closestDirectDistance.py
closestDirectDistance
def closestDirectDistance(arr, ksize=30, dtype=np.uint16): ''' return an array with contains the closest distance to the next positive value given in arr within a given kernel size ''' out = np.zeros_like(arr, dtype=dtype) _calc(out, arr, ksize) return out
python
def closestDirectDistance(arr, ksize=30, dtype=np.uint16): ''' return an array with contains the closest distance to the next positive value given in arr within a given kernel size ''' out = np.zeros_like(arr, dtype=dtype) _calc(out, arr, ksize) return out
[ "def", "closestDirectDistance", "(", "arr", ",", "ksize", "=", "30", ",", "dtype", "=", "np", ".", "uint16", ")", ":", "out", "=", "np", ".", "zeros_like", "(", "arr", ",", "dtype", "=", "dtype", ")", "_calc", "(", "out", ",", "arr", ",", "ksize", ...
return an array with contains the closest distance to the next positive value given in arr within a given kernel size
[ "return", "an", "array", "with", "contains", "the", "closest", "distance", "to", "the", "next", "positive", "value", "given", "in", "arr", "within", "a", "given", "kernel", "size" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestDirectDistance.py#L6-L14
radjkarl/imgProcessor
imgProcessor/render/closestConnectedDistance.py
closestConnectedDistance
def closestConnectedDistance(target, walls=None, max_len_border_line=500, max_n_path=100, concentrate_every_n_pixel=1): ''' returns an array with contains the closest distance from every pixel the next position wher...
python
def closestConnectedDistance(target, walls=None, max_len_border_line=500, max_n_path=100, concentrate_every_n_pixel=1): ''' returns an array with contains the closest distance from every pixel the next position wher...
[ "def", "closestConnectedDistance", "(", "target", ",", "walls", "=", "None", ",", "max_len_border_line", "=", "500", ",", "max_n_path", "=", "100", ",", "concentrate_every_n_pixel", "=", "1", ")", ":", "c", "=", "concentrate_every_n_pixel", "assert", "c", ">=", ...
returns an array with contains the closest distance from every pixel the next position where target == 1 [walls] binary 2darray - e.g. walls in a labyrinth that have to be surrounded in order to get to the target [target] binary 2darray - positions given by 1 [concentrate_every_n_pixel] often ...
[ "returns", "an", "array", "with", "contains", "the", "closest", "distance", "from", "every", "pixel", "the", "next", "position", "where", "target", "==", "1", "[", "walls", "]", "binary", "2darray", "-", "e", ".", "g", ".", "walls", "in", "a", "labyrinth...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestConnectedDistance.py#L14-L77
radjkarl/imgProcessor
imgProcessor/render/closestConnectedDistance.py
_grow
def _grow(growth, walls, target, i, j, steps, new_steps, res): ''' fills [res] with [distance to next position where target == 1, x coord., y coord. of that position in target] using region growth i,j -> pixel position growth -> a work array, ne...
python
def _grow(growth, walls, target, i, j, steps, new_steps, res): ''' fills [res] with [distance to next position where target == 1, x coord., y coord. of that position in target] using region growth i,j -> pixel position growth -> a work array, ne...
[ "def", "_grow", "(", "growth", ",", "walls", ",", "target", ",", "i", ",", "j", ",", "steps", ",", "new_steps", ",", "res", ")", ":", "# clean array:\r", "growth", "[", ":", "]", "=", "0", "if", "target", "[", "i", ",", "j", "]", ":", "# pixel is...
fills [res] with [distance to next position where target == 1, x coord., y coord. of that position in target] using region growth i,j -> pixel position growth -> a work array, needed to measure the distance steps, new_steps -> current and last posit...
[ "fills", "[", "res", "]", "with", "[", "distance", "to", "next", "position", "where", "target", "==", "1", "x", "coord", ".", "y", "coord", ".", "of", "that", "position", "in", "target", "]", "using", "region", "growth", "i", "j", "-", ">", "pixel", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestConnectedDistance.py#L100-L166
radjkarl/imgProcessor
imgProcessor/features/polylinesFromBinImage.py
polylinesFromBinImage
def polylinesFromBinImage(img, minimum_cluster_size=6, remove_small_obj_size=3, reconnect_size=3, max_n_contours=None, max_len_contour=None, copy=True): ''' return a list of arrays of un-branching conto...
python
def polylinesFromBinImage(img, minimum_cluster_size=6, remove_small_obj_size=3, reconnect_size=3, max_n_contours=None, max_len_contour=None, copy=True): ''' return a list of arrays of un-branching conto...
[ "def", "polylinesFromBinImage", "(", "img", ",", "minimum_cluster_size", "=", "6", ",", "remove_small_obj_size", "=", "3", ",", "reconnect_size", "=", "3", ",", "max_n_contours", "=", "None", ",", "max_len_contour", "=", "None", ",", "copy", "=", "True", ")", ...
return a list of arrays of un-branching contours img -> (boolean) array optional: --------- minimum_cluster_size -> minimum number of pixels connected together to build a contour ##search_kernel_size -> TODO ##min_search_kernel_moment -> TODO numeric: ------------- ...
[ "return", "a", "list", "of", "arrays", "of", "un", "-", "branching", "contours", "img", "-", ">", "(", "boolean", ")", "array", "optional", ":", "---------", "minimum_cluster_size", "-", ">", "minimum", "number", "of", "pixels", "connected", "together", "to"...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/polylinesFromBinImage.py#L14-L73
radjkarl/imgProcessor
imgProcessor/utils/cdf.py
cdf
def cdf(arr, pos=None): ''' Return the cumulative density function of a given array or its intensity at a given position (0-1) ''' r = (arr.min(), arr.max()) hist, bin_edges = np.histogram(arr, bins=2 * int(r[1] - r[0]), range=r) hist = np.asfarray(hist) / hist.sum() cdf = np.c...
python
def cdf(arr, pos=None): ''' Return the cumulative density function of a given array or its intensity at a given position (0-1) ''' r = (arr.min(), arr.max()) hist, bin_edges = np.histogram(arr, bins=2 * int(r[1] - r[0]), range=r) hist = np.asfarray(hist) / hist.sum() cdf = np.c...
[ "def", "cdf", "(", "arr", ",", "pos", "=", "None", ")", ":", "r", "=", "(", "arr", ".", "min", "(", ")", ",", "arr", ".", "max", "(", ")", ")", "hist", ",", "bin_edges", "=", "np", ".", "histogram", "(", "arr", ",", "bins", "=", "2", "*", ...
Return the cumulative density function of a given array or its intensity at a given position (0-1)
[ "Return", "the", "cumulative", "density", "function", "of", "a", "given", "array", "or", "its", "intensity", "at", "a", "given", "position", "(", "0", "-", "1", ")" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/cdf.py#L7-L20
radjkarl/imgProcessor
imgProcessor/array/subCell2D.py
subCell2DGenerator
def subCell2DGenerator(arr, shape, d01=None, p01=None): '''Generator to access evenly sized sub-cells in a 2d array Args: shape (tuple): number of sub-cells in y,x e.g. (10,15) d01 (tuple, optional): cell size in y and x p01 (tuple, optional): position of top left edge Returns...
python
def subCell2DGenerator(arr, shape, d01=None, p01=None): '''Generator to access evenly sized sub-cells in a 2d array Args: shape (tuple): number of sub-cells in y,x e.g. (10,15) d01 (tuple, optional): cell size in y and x p01 (tuple, optional): position of top left edge Returns...
[ "def", "subCell2DGenerator", "(", "arr", ",", "shape", ",", "d01", "=", "None", ",", "p01", "=", "None", ")", ":", "for", "i", ",", "j", ",", "s0", ",", "s1", "in", "subCell2DSlices", "(", "arr", ",", "shape", ",", "d01", ",", "p01", ")", ":", ...
Generator to access evenly sized sub-cells in a 2d array Args: shape (tuple): number of sub-cells in y,x e.g. (10,15) d01 (tuple, optional): cell size in y and x p01 (tuple, optional): position of top left edge Returns: int: 1st index int: 2nd index array...
[ "Generator", "to", "access", "evenly", "sized", "sub", "-", "cells", "in", "a", "2d", "array", "Args", ":", "shape", "(", "tuple", ")", ":", "number", "of", "sub", "-", "cells", "in", "y", "x", "e", ".", "g", ".", "(", "10", "15", ")", "d01", "...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L5-L29
radjkarl/imgProcessor
imgProcessor/array/subCell2D.py
subCell2DSlices
def subCell2DSlices(arr, shape, d01=None, p01=None): '''Generator to access evenly sized sub-cells in a 2d array Args: shape (tuple): number of sub-cells in y,x e.g. (10,15) d01 (tuple, optional): cell size in y and x p01 (tuple, optional): position of top left edge Returns: ...
python
def subCell2DSlices(arr, shape, d01=None, p01=None): '''Generator to access evenly sized sub-cells in a 2d array Args: shape (tuple): number of sub-cells in y,x e.g. (10,15) d01 (tuple, optional): cell size in y and x p01 (tuple, optional): position of top left edge Returns: ...
[ "def", "subCell2DSlices", "(", "arr", ",", "shape", ",", "d01", "=", "None", ",", "p01", "=", "None", ")", ":", "if", "p01", "is", "not", "None", ":", "yinit", ",", "xinit", "=", "p01", "else", ":", "xinit", ",", "yinit", "=", "0", ",", "0", "x...
Generator to access evenly sized sub-cells in a 2d array Args: shape (tuple): number of sub-cells in y,x e.g. (10,15) d01 (tuple, optional): cell size in y and x p01 (tuple, optional): position of top left edge Returns: int: 1st index int: 2nd index slice...
[ "Generator", "to", "access", "evenly", "sized", "sub", "-", "cells", "in", "a", "2d", "array", "Args", ":", "shape", "(", "tuple", ")", ":", "number", "of", "sub", "-", "cells", "in", "y", "x", "e", ".", "g", ".", "(", "10", "15", ")", "d01", "...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L32-L71
radjkarl/imgProcessor
imgProcessor/array/subCell2D.py
subCell2DCoords
def subCell2DCoords(*args, **kwargs): '''Same as subCell2DSlices but returning coordinates Example: g = subCell2DCoords(arr, shape) for x, y in g: plt.plot(x, y) ''' for _, _, s0, s1 in subCell2DSlices(*args, **kwargs): yield ((s1.start, s1.start, s1.sto...
python
def subCell2DCoords(*args, **kwargs): '''Same as subCell2DSlices but returning coordinates Example: g = subCell2DCoords(arr, shape) for x, y in g: plt.plot(x, y) ''' for _, _, s0, s1 in subCell2DSlices(*args, **kwargs): yield ((s1.start, s1.start, s1.sto...
[ "def", "subCell2DCoords", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "_", ",", "_", ",", "s0", ",", "s1", "in", "subCell2DSlices", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "yield", "(", "(", "s1", ".", "start", ",",...
Same as subCell2DSlices but returning coordinates Example: g = subCell2DCoords(arr, shape) for x, y in g: plt.plot(x, y)
[ "Same", "as", "subCell2DSlices", "but", "returning", "coordinates", "Example", ":", "g", "=", "subCell2DCoords", "(", "arr", "shape", ")", "for", "x", "y", "in", "g", ":", "plt", ".", "plot", "(", "x", "y", ")" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L74-L84
radjkarl/imgProcessor
imgProcessor/array/subCell2D.py
subCell2DFnArray
def subCell2DFnArray(arr, fn, shape, dtype=None, **kwargs): ''' Return array where every cell is the output of a given cell function Args: fn (function): ...to be executed on all sub-arrays Returns: array: value of every cell equals result of fn(sub-array) Example: ...
python
def subCell2DFnArray(arr, fn, shape, dtype=None, **kwargs): ''' Return array where every cell is the output of a given cell function Args: fn (function): ...to be executed on all sub-arrays Returns: array: value of every cell equals result of fn(sub-array) Example: ...
[ "def", "subCell2DFnArray", "(", "arr", ",", "fn", ",", "shape", ",", "dtype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "sh", "=", "list", "(", "arr", ".", "shape", ")", "sh", "[", ":", "2", "]", "=", "shape", "out", "=", "np", ".", "em...
Return array where every cell is the output of a given cell function Args: fn (function): ...to be executed on all sub-arrays Returns: array: value of every cell equals result of fn(sub-array) Example: mx = subCell2DFnArray(myArray, np.max, (10,6) ) - -> here ...
[ "Return", "array", "where", "every", "cell", "is", "the", "output", "of", "a", "given", "cell", "function", "Args", ":", "fn", "(", "function", ")", ":", "...", "to", "be", "executed", "on", "all", "sub", "-", "arrays", "Returns", ":", "array", ":", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L87-L107
radjkarl/imgProcessor
imgProcessor/equations/defocusThroughDepth.py
defocusThroughDepth
def defocusThroughDepth(u, uf, f, fn, k=2.355): ''' return the defocus (mm std) through DOF u -> scene point (depth value) uf -> in-focus position (the distance at which the scene point should be placed in order to be focused) f -> focal length k -> camera dependent constant (transfe...
python
def defocusThroughDepth(u, uf, f, fn, k=2.355): ''' return the defocus (mm std) through DOF u -> scene point (depth value) uf -> in-focus position (the distance at which the scene point should be placed in order to be focused) f -> focal length k -> camera dependent constant (transfe...
[ "def", "defocusThroughDepth", "(", "u", ",", "uf", ",", "f", ",", "fn", ",", "k", "=", "2.355", ")", ":", "# A = f/fn \r", "return", "(", "k", "/", "fn", ")", "*", "(", "f", "**", "2", "*", "abs", "(", "u", "-", "uf", ")", ")", "/", "(", "u...
return the defocus (mm std) through DOF u -> scene point (depth value) uf -> in-focus position (the distance at which the scene point should be placed in order to be focused) f -> focal length k -> camera dependent constant (transferring blur circle to PSF), 2.335 would be FHWD of 2dgaussian ...
[ "return", "the", "defocus", "(", "mm", "std", ")", "through", "DOF", "u", "-", ">", "scene", "point", "(", "depth", "value", ")", "uf", "-", ">", "in", "-", "focus", "position", "(", "the", "distance", "at", "which", "the", "scene", "point", "should"...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/defocusThroughDepth.py#L4-L22
radjkarl/imgProcessor
imgProcessor/filters/_extendArrayForConvolution.py
extendArrayForConvolution
def extendArrayForConvolution(arr, kernelXY, modex='reflect', modey='reflect'): ''' extends a given array right right border handling for convolution -->in opposite to skimage and skipy this function allows to chose different mode = ('ref...
python
def extendArrayForConvolution(arr, kernelXY, modex='reflect', modey='reflect'): ''' extends a given array right right border handling for convolution -->in opposite to skimage and skipy this function allows to chose different mode = ('ref...
[ "def", "extendArrayForConvolution", "(", "arr", ",", "kernelXY", ",", "modex", "=", "'reflect'", ",", "modey", "=", "'reflect'", ")", ":", "(", "kx", ",", "ky", ")", "=", "kernelXY", "kx", "//=", "2", "ky", "//=", "2", "#indexing 0:-0 leads to empty arrays a...
extends a given array right right border handling for convolution -->in opposite to skimage and skipy this function allows to chose different mode = ('reflect', 'wrap') in x and y direction only supports 'warp' and 'reflect' at the moment
[ "extends", "a", "given", "array", "right", "right", "border", "handling", "for", "convolution", "--", ">", "in", "opposite", "to", "skimage", "and", "skipy", "this", "function", "allows", "to", "chose", "different", "mode", "=", "(", "reflect", "wrap", ")", ...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/_extendArrayForConvolution.py#L5-L97
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.calibrate
def calibrate(self, board_size=(8, 6), method='Chessboard', images=[], max_images=100, sensorSize_mm=None, detect_sensible=True): ''' sensorSize_mm - (width, height) [mm] Physical size of the sensor ''' self._coeffs = {} self.opts = {'fo...
python
def calibrate(self, board_size=(8, 6), method='Chessboard', images=[], max_images=100, sensorSize_mm=None, detect_sensible=True): ''' sensorSize_mm - (width, height) [mm] Physical size of the sensor ''' self._coeffs = {} self.opts = {'fo...
[ "def", "calibrate", "(", "self", ",", "board_size", "=", "(", "8", ",", "6", ")", ",", "method", "=", "'Chessboard'", ",", "images", "=", "[", "]", ",", "max_images", "=", "100", ",", "sensorSize_mm", "=", "None", ",", "detect_sensible", "=", "True", ...
sensorSize_mm - (width, height) [mm] Physical size of the sensor
[ "sensorSize_mm", "-", "(", "width", "height", ")", "[", "mm", "]", "Physical", "size", "of", "the", "sensor" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L35-L80
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.addPoints
def addPoints(self, points, board_size=None): ''' add corner points directly instead of extracting them from image points = ( (0,1), (...),... ) [x,y] ''' self.opts['foundPattern'].append(True) self.findCount += 1 if board_size is not None: ...
python
def addPoints(self, points, board_size=None): ''' add corner points directly instead of extracting them from image points = ( (0,1), (...),... ) [x,y] ''' self.opts['foundPattern'].append(True) self.findCount += 1 if board_size is not None: ...
[ "def", "addPoints", "(", "self", ",", "points", ",", "board_size", "=", "None", ")", ":", "self", ".", "opts", "[", "'foundPattern'", "]", ".", "append", "(", "True", ")", "self", ".", "findCount", "+=", "1", "if", "board_size", "is", "not", "None", ...
add corner points directly instead of extracting them from image points = ( (0,1), (...),... ) [x,y]
[ "add", "corner", "points", "directly", "instead", "of", "extracting", "them", "from", "image", "points", "=", "(", "(", "0", "1", ")", "(", "...", ")", "...", ")", "[", "x", "y", "]" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L91-L106
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.setImgShape
def setImgShape(self, shape): ''' image shape must be known for calculating camera matrix if method==Manual and addPoints is used instead of addImg this method must be called before .coeffs are obtained ''' self.img = type('Dummy', (object,), {}) # if imgPr...
python
def setImgShape(self, shape): ''' image shape must be known for calculating camera matrix if method==Manual and addPoints is used instead of addImg this method must be called before .coeffs are obtained ''' self.img = type('Dummy', (object,), {}) # if imgPr...
[ "def", "setImgShape", "(", "self", ",", "shape", ")", ":", "self", ".", "img", "=", "type", "(", "'Dummy'", ",", "(", "object", ",", ")", ",", "{", "}", ")", "# if imgProcessor.ARRAYS_ORDER_IS_XY:\r", "# self.img.shape = shape[::-1]\r", "# ...
image shape must be known for calculating camera matrix if method==Manual and addPoints is used instead of addImg this method must be called before .coeffs are obtained
[ "image", "shape", "must", "be", "known", "for", "calculating", "camera", "matrix", "if", "method", "==", "Manual", "and", "addPoints", "is", "used", "instead", "of", "addImg", "this", "method", "must", "be", "called", "before", ".", "coeffs", "are", "obtaine...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L108-L118
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.addImgStream
def addImgStream(self, img): ''' add images using a continous stream - stop when max number of images is reached ''' if self.findCount > self.max_images: raise EnoughImages('have enough images') return self.addImg(img)
python
def addImgStream(self, img): ''' add images using a continous stream - stop when max number of images is reached ''' if self.findCount > self.max_images: raise EnoughImages('have enough images') return self.addImg(img)
[ "def", "addImgStream", "(", "self", ",", "img", ")", ":", "if", "self", ".", "findCount", ">", "self", ".", "max_images", ":", "raise", "EnoughImages", "(", "'have enough images'", ")", "return", "self", ".", "addImg", "(", "img", ")" ]
add images using a continous stream - stop when max number of images is reached
[ "add", "images", "using", "a", "continous", "stream", "-", "stop", "when", "max", "number", "of", "images", "is", "reached" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L120-L127
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.addImg
def addImg(self, img): ''' add one chessboard image for detection lens distortion ''' # self.opts['imgs'].append(img) self.img = imread(img, 'gray', 'uint8') didFindCorners, corners = self.method() self.opts['foundPattern'].append(didFindCorners) ...
python
def addImg(self, img): ''' add one chessboard image for detection lens distortion ''' # self.opts['imgs'].append(img) self.img = imread(img, 'gray', 'uint8') didFindCorners, corners = self.method() self.opts['foundPattern'].append(didFindCorners) ...
[ "def", "addImg", "(", "self", ",", "img", ")", ":", "# self.opts['imgs'].append(img)\r", "self", ".", "img", "=", "imread", "(", "img", ",", "'gray'", ",", "'uint8'", ")", "didFindCorners", ",", "corners", "=", "self", ".", "method", "(", ")", "self", "....
add one chessboard image for detection lens distortion
[ "add", "one", "chessboard", "image", "for", "detection", "lens", "distortion" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L129-L144
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.getCoeffStr
def getCoeffStr(self): ''' get the distortion coeffs in a formated string ''' txt = '' for key, val in self.coeffs.items(): txt += '%s = %s\n' % (key, val) return txt
python
def getCoeffStr(self): ''' get the distortion coeffs in a formated string ''' txt = '' for key, val in self.coeffs.items(): txt += '%s = %s\n' % (key, val) return txt
[ "def", "getCoeffStr", "(", "self", ")", ":", "txt", "=", "''", "for", "key", ",", "val", "in", "self", ".", "coeffs", ".", "items", "(", ")", ":", "txt", "+=", "'%s = %s\\n'", "%", "(", "key", ",", "val", ")", "return", "txt" ]
get the distortion coeffs in a formated string
[ "get", "the", "distortion", "coeffs", "in", "a", "formated", "string" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L177-L184
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.drawChessboard
def drawChessboard(self, img=None): ''' draw a grid fitting to the last added image on this one or an extra image img == None ==False -> draw chessbord on empty image ==img ''' assert self.findCount > 0, 'cannot draw chessboard if nothing f...
python
def drawChessboard(self, img=None): ''' draw a grid fitting to the last added image on this one or an extra image img == None ==False -> draw chessbord on empty image ==img ''' assert self.findCount > 0, 'cannot draw chessboard if nothing f...
[ "def", "drawChessboard", "(", "self", ",", "img", "=", "None", ")", ":", "assert", "self", ".", "findCount", ">", "0", ",", "'cannot draw chessboard if nothing found'", "if", "img", "is", "None", ":", "img", "=", "self", ".", "img", "elif", "isinstance", "...
draw a grid fitting to the last added image on this one or an extra image img == None ==False -> draw chessbord on empty image ==img
[ "draw", "a", "grid", "fitting", "to", "the", "last", "added", "image", "on", "this", "one", "or", "an", "extra", "image", "img", "==", "None", "==", "False", "-", ">", "draw", "chessbord", "on", "empty", "image", "==", "img" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L186-L212
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.writeToFile
def writeToFile(self, filename, saveOpts=False): ''' write the distortion coeffs to file saveOpts --> Whether so save calibration options (and not just results) ''' try: if not filename.endswith('.%s' % self.ftype): filename += '.%s' % self.ftyp...
python
def writeToFile(self, filename, saveOpts=False): ''' write the distortion coeffs to file saveOpts --> Whether so save calibration options (and not just results) ''' try: if not filename.endswith('.%s' % self.ftype): filename += '.%s' % self.ftyp...
[ "def", "writeToFile", "(", "self", ",", "filename", ",", "saveOpts", "=", "False", ")", ":", "try", ":", "if", "not", "filename", ".", "endswith", "(", "'.%s'", "%", "self", ".", "ftype", ")", ":", "filename", "+=", "'.%s'", "%", "self", ".", "ftype"...
write the distortion coeffs to file saveOpts --> Whether so save calibration options (and not just results)
[ "write", "the", "distortion", "coeffs", "to", "file", "saveOpts", "--", ">", "Whether", "so", "save", "calibration", "options", "(", "and", "not", "just", "results", ")" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L258-L275
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.readFromFile
def readFromFile(self, filename): ''' read the distortion coeffs from file ''' s = dict(np.load(filename)) try: self.coeffs = s['coeffs'][()] except KeyError: #LEGENCY - remove self.coeffs = s try: self.op...
python
def readFromFile(self, filename): ''' read the distortion coeffs from file ''' s = dict(np.load(filename)) try: self.coeffs = s['coeffs'][()] except KeyError: #LEGENCY - remove self.coeffs = s try: self.op...
[ "def", "readFromFile", "(", "self", ",", "filename", ")", ":", "s", "=", "dict", "(", "np", ".", "load", "(", "filename", ")", ")", "try", ":", "self", ".", "coeffs", "=", "s", "[", "'coeffs'", "]", "[", "(", ")", "]", "except", "KeyError", ":", ...
read the distortion coeffs from file
[ "read", "the", "distortion", "coeffs", "from", "file" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L277-L291
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.undistortPoints
def undistortPoints(self, points, keepSize=False): ''' points --> list of (x,y) coordinates ''' s = self.img.shape cam = self.coeffs['cameraMatrix'] d = self.coeffs['distortionCoeffs'] pts = np.asarray(points, dtype=np.float32) if pts.ndim == 2: ...
python
def undistortPoints(self, points, keepSize=False): ''' points --> list of (x,y) coordinates ''' s = self.img.shape cam = self.coeffs['cameraMatrix'] d = self.coeffs['distortionCoeffs'] pts = np.asarray(points, dtype=np.float32) if pts.ndim == 2: ...
[ "def", "undistortPoints", "(", "self", ",", "points", ",", "keepSize", "=", "False", ")", ":", "s", "=", "self", ".", "img", ".", "shape", "cam", "=", "self", ".", "coeffs", "[", "'cameraMatrix'", "]", "d", "=", "self", ".", "coeffs", "[", "'distorti...
points --> list of (x,y) coordinates
[ "points", "--", ">", "list", "of", "(", "x", "y", ")", "coordinates" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L293-L314
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.correct
def correct(self, image, keepSize=False, borderValue=0): ''' remove lens distortion from given image ''' image = imread(image) (h, w) = image.shape[:2] mapx, mapy = self.getUndistortRectifyMap(w, h) self.img = cv2.remap(image, mapx, mapy, cv2.INTER_LINEAR, ...
python
def correct(self, image, keepSize=False, borderValue=0): ''' remove lens distortion from given image ''' image = imread(image) (h, w) = image.shape[:2] mapx, mapy = self.getUndistortRectifyMap(w, h) self.img = cv2.remap(image, mapx, mapy, cv2.INTER_LINEAR, ...
[ "def", "correct", "(", "self", ",", "image", ",", "keepSize", "=", "False", ",", "borderValue", "=", "0", ")", ":", "image", "=", "imread", "(", "image", ")", "(", "h", ",", "w", ")", "=", "image", ".", "shape", "[", ":", "2", "]", "mapx", ",",...
remove lens distortion from given image
[ "remove", "lens", "distortion", "from", "given", "image" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L316-L330
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.distortImage
def distortImage(self, image): ''' opposite of 'correct' ''' image = imread(image) (imgHeight, imgWidth) = image.shape[:2] mapx, mapy = self.getDistortRectifyMap(imgWidth, imgHeight) return cv2.remap(image, mapx, mapy, cv2.INTER_LINEAR, ...
python
def distortImage(self, image): ''' opposite of 'correct' ''' image = imread(image) (imgHeight, imgWidth) = image.shape[:2] mapx, mapy = self.getDistortRectifyMap(imgWidth, imgHeight) return cv2.remap(image, mapx, mapy, cv2.INTER_LINEAR, ...
[ "def", "distortImage", "(", "self", ",", "image", ")", ":", "image", "=", "imread", "(", "image", ")", "(", "imgHeight", ",", "imgWidth", ")", "=", "image", ".", "shape", "[", ":", "2", "]", "mapx", ",", "mapy", "=", "self", ".", "getDistortRectifyMa...
opposite of 'correct'
[ "opposite", "of", "correct" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L332-L340
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.getCameraParams
def getCameraParams(self): ''' value positions based on http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#cv.InitUndistortRectifyMap ''' c = self.coeffs['cameraMatrix'] fx = c[0][0] fy = c[1][1] cx = c[0][2] cy = c...
python
def getCameraParams(self): ''' value positions based on http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#cv.InitUndistortRectifyMap ''' c = self.coeffs['cameraMatrix'] fx = c[0][0] fy = c[1][1] cx = c[0][2] cy = c...
[ "def", "getCameraParams", "(", "self", ")", ":", "c", "=", "self", ".", "coeffs", "[", "'cameraMatrix'", "]", "fx", "=", "c", "[", "0", "]", "[", "0", "]", "fy", "=", "c", "[", "1", "]", "[", "1", "]", "cx", "=", "c", "[", "0", "]", "[", ...
value positions based on http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#cv.InitUndistortRectifyMap
[ "value", "positions", "based", "on", "http", ":", "//", "docs", ".", "opencv", ".", "org", "/", "modules", "/", "imgproc", "/", "doc", "/", "geometric_transformations", ".", "html#cv", ".", "InitUndistortRectifyMap" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L360-L371
radjkarl/imgProcessor
imgProcessor/camera/LensDistortion.py
LensDistortion.standardUncertainties
def standardUncertainties(self, sharpness=0.5): ''' sharpness -> image sharpness // std of Gaussian PSF [px] returns a list of standard uncertainties for the x and y component: (1x,2x), (1y, 2y), (intensity:None) 1. px-size-changes(due to deflection) 2. reprojecti...
python
def standardUncertainties(self, sharpness=0.5): ''' sharpness -> image sharpness // std of Gaussian PSF [px] returns a list of standard uncertainties for the x and y component: (1x,2x), (1y, 2y), (intensity:None) 1. px-size-changes(due to deflection) 2. reprojecti...
[ "def", "standardUncertainties", "(", "self", ",", "sharpness", "=", "0.5", ")", ":", "height", ",", "width", "=", "self", ".", "coeffs", "[", "'shape'", "]", "fx", ",", "fy", "=", "self", ".", "getDeflection", "(", "width", ",", "height", ")", "# is RM...
sharpness -> image sharpness // std of Gaussian PSF [px] returns a list of standard uncertainties for the x and y component: (1x,2x), (1y, 2y), (intensity:None) 1. px-size-changes(due to deflection) 2. reprojection error
[ "sharpness", "-", ">", "image", "sharpness", "//", "std", "of", "Gaussian", "PSF", "[", "px", "]", "returns", "a", "list", "of", "standard", "uncertainties", "for", "the", "x", "and", "y", "component", ":", "(", "1x", "2x", ")", "(", "1y", "2y", ")",...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L404-L418
radjkarl/imgProcessor
imgProcessor/filters/edgesFromBoolImg.py
edgesFromBoolImg
def edgesFromBoolImg(arr, dtype=None): ''' takes a binary image (usually a mask) and returns the edges of the object inside ''' out = np.zeros_like(arr, dtype=dtype) _calc(arr, out) _calc(arr.T, out.T) return out
python
def edgesFromBoolImg(arr, dtype=None): ''' takes a binary image (usually a mask) and returns the edges of the object inside ''' out = np.zeros_like(arr, dtype=dtype) _calc(arr, out) _calc(arr.T, out.T) return out
[ "def", "edgesFromBoolImg", "(", "arr", ",", "dtype", "=", "None", ")", ":", "out", "=", "np", ".", "zeros_like", "(", "arr", ",", "dtype", "=", "dtype", ")", "_calc", "(", "arr", ",", "out", ")", "_calc", "(", "arr", ".", "T", ",", "out", ".", ...
takes a binary image (usually a mask) and returns the edges of the object inside
[ "takes", "a", "binary", "image", "(", "usually", "a", "mask", ")", "and", "returns", "the", "edges", "of", "the", "object", "inside" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/edgesFromBoolImg.py#L5-L13
radjkarl/imgProcessor
imgProcessor/features/PatternRecognition.py
draw_matches
def draw_matches(img1, kp1, img2, kp2, matches, color=None, thickness=2, r=15): """Draws lines between matching keypoints of two images. Keypoints not in a matching pair are not drawn. Places the images side by side in a new image and draws circles around each keypoint, with line segments connect...
python
def draw_matches(img1, kp1, img2, kp2, matches, color=None, thickness=2, r=15): """Draws lines between matching keypoints of two images. Keypoints not in a matching pair are not drawn. Places the images side by side in a new image and draws circles around each keypoint, with line segments connect...
[ "def", "draw_matches", "(", "img1", ",", "kp1", ",", "img2", ",", "kp2", ",", "matches", ",", "color", "=", "None", ",", "thickness", "=", "2", ",", "r", "=", "15", ")", ":", "# We're drawing them side by side. Get dimensions accordingly.\r", "# Handle both col...
Draws lines between matching keypoints of two images. Keypoints not in a matching pair are not drawn. Places the images side by side in a new image and draws circles around each keypoint, with line segments connecting matching pairs. You can tweak the r, thickness, and figsize values as needed. ...
[ "Draws", "lines", "between", "matching", "keypoints", "of", "two", "images", ".", "Keypoints", "not", "in", "a", "matching", "pair", "are", "not", "drawn", ".", "Places", "the", "images", "side", "by", "side", "in", "a", "new", "image", "and", "draws", "...
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L203-L252
radjkarl/imgProcessor
imgProcessor/features/PatternRecognition.py
PatternRecognition._scaleTo8bit
def _scaleTo8bit(self, img): ''' The pattern comparator need images to be 8 bit -> find the range of the signal and scale the image ''' r = scaleSignalCutParams(img, 0.02) # , nSigma=3) self.signal_ranges.append(r) return toUIntArray(img, dtype=np.uint8, r...
python
def _scaleTo8bit(self, img): ''' The pattern comparator need images to be 8 bit -> find the range of the signal and scale the image ''' r = scaleSignalCutParams(img, 0.02) # , nSigma=3) self.signal_ranges.append(r) return toUIntArray(img, dtype=np.uint8, r...
[ "def", "_scaleTo8bit", "(", "self", ",", "img", ")", ":", "r", "=", "scaleSignalCutParams", "(", "img", ",", "0.02", ")", "# , nSigma=3)\r", "self", ".", "signal_ranges", ".", "append", "(", "r", ")", "return", "toUIntArray", "(", "img", ",", "dtype", "=...
The pattern comparator need images to be 8 bit -> find the range of the signal and scale the image
[ "The", "pattern", "comparator", "need", "images", "to", "be", "8", "bit", "-", ">", "find", "the", "range", "of", "the", "signal", "and", "scale", "the", "image" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L89-L96
radjkarl/imgProcessor
imgProcessor/features/PatternRecognition.py
PatternRecognition.findHomography
def findHomography(self, img, drawMatches=False): ''' Find homography of the image through pattern comparison with the base image ''' print("\t Finding points...") # Find points in the next frame img = self._prepareImage(img) features, descs = self...
python
def findHomography(self, img, drawMatches=False): ''' Find homography of the image through pattern comparison with the base image ''' print("\t Finding points...") # Find points in the next frame img = self._prepareImage(img) features, descs = self...
[ "def", "findHomography", "(", "self", ",", "img", ",", "drawMatches", "=", "False", ")", ":", "print", "(", "\"\\t Finding points...\"", ")", "# Find points in the next frame\r", "img", "=", "self", ".", "_prepareImage", "(", "img", ")", "features", ",", "descs"...
Find homography of the image through pattern comparison with the base image
[ "Find", "homography", "of", "the", "image", "through", "pattern", "comparison", "with", "the", "base", "image" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L108-L196
radjkarl/imgProcessor
imgProcessor/generate/patterns.py
patCircles
def patCircles(s0): '''make circle array''' arr = np.zeros((s0,s0), dtype=np.uint8) col = 255 for rad in np.linspace(s0,s0/7.,10): cv2.circle(arr, (0,0), int(round(rad)), color=col, thickness=-1, lineType=cv2.LINE_AA ) if col: col = 0 else...
python
def patCircles(s0): '''make circle array''' arr = np.zeros((s0,s0), dtype=np.uint8) col = 255 for rad in np.linspace(s0,s0/7.,10): cv2.circle(arr, (0,0), int(round(rad)), color=col, thickness=-1, lineType=cv2.LINE_AA ) if col: col = 0 else...
[ "def", "patCircles", "(", "s0", ")", ":", "arr", "=", "np", ".", "zeros", "(", "(", "s0", ",", "s0", ")", ",", "dtype", "=", "np", ".", "uint8", ")", "col", "=", "255", "for", "rad", "in", "np", ".", "linspace", "(", "s0", ",", "s0", "/", "...
make circle array
[ "make", "circle", "array" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L5-L18
radjkarl/imgProcessor
imgProcessor/generate/patterns.py
patCrossLines
def patCrossLines(s0): '''make line pattern''' arr = np.zeros((s0,s0), dtype=np.uint8) col = 255 t = int(s0/100.) for pos in np.logspace(0.01,1,10): pos = int(round((pos-0.5)*s0/10.)) cv2.line(arr, (0,pos), (s0,pos), color=col, thickness=t, lineType=cv2.LI...
python
def patCrossLines(s0): '''make line pattern''' arr = np.zeros((s0,s0), dtype=np.uint8) col = 255 t = int(s0/100.) for pos in np.logspace(0.01,1,10): pos = int(round((pos-0.5)*s0/10.)) cv2.line(arr, (0,pos), (s0,pos), color=col, thickness=t, lineType=cv2.LI...
[ "def", "patCrossLines", "(", "s0", ")", ":", "arr", "=", "np", ".", "zeros", "(", "(", "s0", ",", "s0", ")", ",", "dtype", "=", "np", ".", "uint8", ")", "col", "=", "255", "t", "=", "int", "(", "s0", "/", "100.", ")", "for", "pos", "in", "n...
make line pattern
[ "make", "line", "pattern" ]
train
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L21-L33