repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L126-L135 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L138-L146 | train |
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##########"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L157-L168 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L186-L209 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transformations.py#L212-L246 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L29-L34 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L37-L49 | train |
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",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L91-L104 | train |
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",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L106-L119 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L121-L164 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L178-L185 | train |
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",
")",
":... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L187-L207 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L209-L219 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L232-L243 | train |
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",
"..."
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L255-L267 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L269-L285 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L287-L298 | train |
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",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L324-L349 | train |
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",
":",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L351-L459 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L461-L474 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L476-L502 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L556-L563 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/CameraCalibration.py#L590-L611 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L324-L352 | train |
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",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L114-L167 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L169-L197 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L294-L310 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L312-L321 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/filterVerticalLines.py#L4-L23 | train |
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",
".",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/vignetting.py#L9-L37 | train |
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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/vignetting.py#L40-L52 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/imgAverage.py#L7-L22 | train |
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",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/offsetMeshgrid.py#L5-L27 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/poisson.py#L4-L15 | train |
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",
"]"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/rotate.py#L8-L19 | train |
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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/adjustUncertToExposureTime.py#L10-L59 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/gaussian.py#L6-L13 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/videoWrite.py#L14-L81 | train |
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",
"..."
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgIO.py#L39-L73 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/SharpnessfromPoints.py#L78-L220 | train |
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",
"+"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredFastIDW.py#L9-L26 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/linearBlend.py#L7-L55 | train |
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",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredPointSpreadIDW.py#L7-L28 | train |
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",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNRaverage.py#L10-L58 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/maskedConvolve.py#L13-L21 | train |
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",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNR.py#L21-L79 | train |
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",
"(",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/sortCorners.py#L8-L50 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestDirectDistance.py#L6-L14 | train |
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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestConnectedDistance.py#L14-L77 | train |
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",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestConnectedDistance.py#L100-L166 | train |
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"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/polylinesFromBinImage.py#L14-L73 | train |
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",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/cdf.py#L7-L20 | train |
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",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L5-L29 | train |
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",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L32-L71 | train |
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",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L74-L84 | train |
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",
":",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L87-L107 | train |
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"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/defocusThroughDepth.py#L4-L22 | train |
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",
")",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/_extendArrayForConvolution.py#L5-L97 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L35-L80 | train |
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",
"]"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L91-L106 | train |
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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L108-L118 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L120-L127 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L129-L144 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L177-L184 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L186-L212 | train |
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",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L258-L275 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L277-L291 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L293-L314 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L316-L330 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L332-L340 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L360-L371 | train |
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",
")",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L404-L418 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/edgesFromBoolImg.py#L5-L13 | train |
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",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L203-L252 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L89-L96 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L108-L196 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L5-L18 | train |
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"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L21-L33 | train |
radjkarl/imgProcessor | imgProcessor/generate/patterns.py | patStarLines | def patStarLines(s0):
'''make line pattern'''
arr = np.zeros((s0,s0), dtype=np.uint8)
col = 255
t = int(s0/100.)
for pos in np.linspace(0,np.pi/2,15):
p0 = int(round(np.sin(pos)*s0*2))
p1 = int(round(np.cos(pos)*s0*2))
cv2.line(arr,(0,0),(p0,p1), co... | python | def patStarLines(s0):
'''make line pattern'''
arr = np.zeros((s0,s0), dtype=np.uint8)
col = 255
t = int(s0/100.)
for pos in np.linspace(0,np.pi/2,15):
p0 = int(round(np.sin(pos)*s0*2))
p1 = int(round(np.cos(pos)*s0*2))
cv2.line(arr,(0,0),(p0,p1), co... | [
"def",
"patStarLines",
"(",
"s0",
")",
":",
"arr",
"=",
"np",
".",
"zeros",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"col",
"=",
"255",
"t",
"=",
"int",
"(",
"s0",
"/",
"100.",
")",
"for",
"pos",
"in",
"np... | make line pattern | [
"make",
"line",
"pattern"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L68-L80 | train |
radjkarl/imgProcessor | imgProcessor/generate/patterns.py | patSiemensStar | def patSiemensStar(s0, n=72, vhigh=255, vlow=0, antiasing=False):
'''make line pattern'''
arr = np.full((s0,s0),vlow, dtype=np.uint8)
c = int(round(s0/2.))
s = 2*np.pi/(2*n)
step = 0
for i in range(2*n):
p0 = round(c+np.sin(step)*2*s0)
p1 = round(c+np.cos(step)*2*s0)
... | python | def patSiemensStar(s0, n=72, vhigh=255, vlow=0, antiasing=False):
'''make line pattern'''
arr = np.full((s0,s0),vlow, dtype=np.uint8)
c = int(round(s0/2.))
s = 2*np.pi/(2*n)
step = 0
for i in range(2*n):
p0 = round(c+np.sin(step)*2*s0)
p1 = round(c+np.cos(step)*2*s0)
... | [
"def",
"patSiemensStar",
"(",
"s0",
",",
"n",
"=",
"72",
",",
"vhigh",
"=",
"255",
",",
"vlow",
"=",
"0",
",",
"antiasing",
"=",
"False",
")",
":",
"arr",
"=",
"np",
".",
"full",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"vlow",
",",
"dtype",
"=",... | make line pattern | [
"make",
"line",
"pattern"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L83-L107 | train |
radjkarl/imgProcessor | imgProcessor/generate/patterns.py | patText | def patText(s0):
'''make text pattern'''
arr = np.zeros((s0,s0), dtype=np.uint8)
s = int(round(s0/100.))
p1 = 0
pp1 = int(round(s0/10.))
for pos0 in np.linspace(0,s0,10):
cv2.putText(arr, 'helloworld', (p1,int(round(pos0))),
cv2.FONT_HERSHEY_COMPLEX_SMALL, fo... | python | def patText(s0):
'''make text pattern'''
arr = np.zeros((s0,s0), dtype=np.uint8)
s = int(round(s0/100.))
p1 = 0
pp1 = int(round(s0/10.))
for pos0 in np.linspace(0,s0,10):
cv2.putText(arr, 'helloworld', (p1,int(round(pos0))),
cv2.FONT_HERSHEY_COMPLEX_SMALL, fo... | [
"def",
"patText",
"(",
"s0",
")",
":",
"arr",
"=",
"np",
".",
"zeros",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"s",
"=",
"int",
"(",
"round",
"(",
"s0",
"/",
"100.",
")",
")",
"p1",
"=",
"0",
"pp1",
"="... | make text pattern | [
"make",
"text",
"pattern"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L140-L155 | train |
radjkarl/imgProcessor | imgProcessor/filters/removeSinglePixels.py | removeSinglePixels | def removeSinglePixels(img):
'''
img - boolean array
remove all pixels that have no neighbour
'''
gx = img.shape[0]
gy = img.shape[1]
for i in range(gx):
for j in range(gy):
if img[i, j]:
found_neighbour = False
for ii in... | python | def removeSinglePixels(img):
'''
img - boolean array
remove all pixels that have no neighbour
'''
gx = img.shape[0]
gy = img.shape[1]
for i in range(gx):
for j in range(gy):
if img[i, j]:
found_neighbour = False
for ii in... | [
"def",
"removeSinglePixels",
"(",
"img",
")",
":",
"gx",
"=",
"img",
".",
"shape",
"[",
"0",
"]",
"gy",
"=",
"img",
".",
"shape",
"[",
"1",
"]",
"for",
"i",
"in",
"range",
"(",
"gx",
")",
":",
"for",
"j",
"in",
"range",
"(",
"gy",
")",
":",
... | img - boolean array
remove all pixels that have no neighbour | [
"img",
"-",
"boolean",
"array",
"remove",
"all",
"pixels",
"that",
"have",
"no",
"neighbour"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/removeSinglePixels.py#L5-L33 | train |
radjkarl/imgProcessor | imgProcessor/interpolate/interpolateCircular2dStructuredIDW.py | interpolateCircular2dStructuredIDW | def interpolateCircular2dStructuredIDW(grid, mask, kernel=15, power=2,
fr=1, fphi=1, cx=0, cy=0):
'''
same as interpolate2dStructuredIDW
but calculation distance to neighbour using polar coordinates
fr, fphi --> weight factors for radian and radius differences
c... | python | def interpolateCircular2dStructuredIDW(grid, mask, kernel=15, power=2,
fr=1, fphi=1, cx=0, cy=0):
'''
same as interpolate2dStructuredIDW
but calculation distance to neighbour using polar coordinates
fr, fphi --> weight factors for radian and radius differences
c... | [
"def",
"interpolateCircular2dStructuredIDW",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
",",
"fr",
"=",
"1",
",",
"fphi",
"=",
"1",
",",
"cx",
"=",
"0",
",",
"cy",
"=",
"0",
")",
":",
"gx",
"=",
"grid",
".",
"sh... | same as interpolate2dStructuredIDW
but calculation distance to neighbour using polar coordinates
fr, fphi --> weight factors for radian and radius differences
cx,cy -> polar center of the array e.g. middle->(sx//2+1,sy//2+1) | [
"same",
"as",
"interpolate2dStructuredIDW",
"but",
"calculation",
"distance",
"to",
"neighbour",
"using",
"polar",
"coordinates",
"fr",
"fphi",
"--",
">",
"weight",
"factors",
"for",
"radian",
"and",
"radius",
"differences",
"cx",
"cy",
"-",
">",
"polar",
"cente... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolateCircular2dStructuredIDW.py#L8-L69 | train |
radjkarl/imgProcessor | imgProcessor/interpolate/interpolate2dStructuredCrossAvg.py | interpolate2dStructuredCrossAvg | def interpolate2dStructuredCrossAvg(grid, mask, kernel=15, power=2):
'''
#######
usefull if large empty areas need to be filled
'''
vals = np.empty(shape=4, dtype=grid.dtype)
dist = np.empty(shape=4, dtype=np.uint16)
weights = np.empty(shape=4, dtype=np.float32)
valid = np.em... | python | def interpolate2dStructuredCrossAvg(grid, mask, kernel=15, power=2):
'''
#######
usefull if large empty areas need to be filled
'''
vals = np.empty(shape=4, dtype=grid.dtype)
dist = np.empty(shape=4, dtype=np.uint16)
weights = np.empty(shape=4, dtype=np.float32)
valid = np.em... | [
"def",
"interpolate2dStructuredCrossAvg",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
")",
":",
"vals",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"4",
",",
"dtype",
"=",
"grid",
".",
"dtype",
")",
"dist",
"=",
"np"... | #######
usefull if large empty areas need to be filled | [
"#######",
"usefull",
"if",
"large",
"empty",
"areas",
"need",
"to",
"be",
"filled"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredCrossAvg.py#L7-L19 | train |
radjkarl/imgProcessor | imgProcessor/utils/growPositions.py | growPositions | def growPositions(ksize):
'''
return all positions around central point (0,0)
for a given kernel size
positions grow from smallest to biggest distances
returns [positions] and [distances] from central cell
'''
i = ksize*2+1
kk = np.ones( (i, i), dtype=bool)
x,y... | python | def growPositions(ksize):
'''
return all positions around central point (0,0)
for a given kernel size
positions grow from smallest to biggest distances
returns [positions] and [distances] from central cell
'''
i = ksize*2+1
kk = np.ones( (i, i), dtype=bool)
x,y... | [
"def",
"growPositions",
"(",
"ksize",
")",
":",
"i",
"=",
"ksize",
"*",
"2",
"+",
"1",
"kk",
"=",
"np",
".",
"ones",
"(",
"(",
"i",
",",
"i",
")",
",",
"dtype",
"=",
"bool",
")",
"x",
",",
"y",
"=",
"np",
".",
"where",
"(",
"kk",
")",
"po... | return all positions around central point (0,0)
for a given kernel size
positions grow from smallest to biggest distances
returns [positions] and [distances] from central cell | [
"return",
"all",
"positions",
"around",
"central",
"point",
"(",
"0",
"0",
")",
"for",
"a",
"given",
"kernel",
"size",
"positions",
"grow",
"from",
"smallest",
"to",
"biggest",
"distances",
"returns",
"[",
"positions",
"]",
"and",
"[",
"distances",
"]",
"f... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/growPositions.py#L5-L31 | train |
radjkarl/imgProcessor | imgProcessor/reader/qImageToArray.py | qImageToArray | def qImageToArray(qimage, dtype = 'array'):
"""Convert QImage to numpy.ndarray. The dtype defaults to uint8
for QImage.Format_Indexed8 or `bgra_dtype` (i.e. a record array)
for 32bit color images. You can pass a different dtype to use, or
'array' to get a 3D uint8 array for color images."""
... | python | def qImageToArray(qimage, dtype = 'array'):
"""Convert QImage to numpy.ndarray. The dtype defaults to uint8
for QImage.Format_Indexed8 or `bgra_dtype` (i.e. a record array)
for 32bit color images. You can pass a different dtype to use, or
'array' to get a 3D uint8 array for color images."""
... | [
"def",
"qImageToArray",
"(",
"qimage",
",",
"dtype",
"=",
"'array'",
")",
":",
"result_shape",
"=",
"(",
"qimage",
".",
"height",
"(",
")",
",",
"qimage",
".",
"width",
"(",
")",
")",
"temp_shape",
"=",
"(",
"qimage",
".",
"height",
"(",
")",
",",
... | Convert QImage to numpy.ndarray. The dtype defaults to uint8
for QImage.Format_Indexed8 or `bgra_dtype` (i.e. a record array)
for 32bit color images. You can pass a different dtype to use, or
'array' to get a 3D uint8 array for color images. | [
"Convert",
"QImage",
"to",
"numpy",
".",
"ndarray",
".",
"The",
"dtype",
"defaults",
"to",
"uint8",
"for",
"QImage",
".",
"Format_Indexed8",
"or",
"bgra_dtype",
"(",
"i",
".",
"e",
".",
"a",
"record",
"array",
")",
"for",
"32bit",
"color",
"images",
".",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/reader/qImageToArray.py#L8-L43 | train |
radjkarl/imgProcessor | imgProcessor/filters/varYSizeGaussianFilter.py | varYSizeGaussianFilter | def varYSizeGaussianFilter(arr, stdyrange, stdx=0,
modex='wrap', modey='reflect'):
'''
applies gaussian_filter on input array
but allowing variable ksize in y
stdyrange(int) -> maximum ksize - ksizes will increase from 0 to given value
stdyrange(tuple,list) -> ... | python | def varYSizeGaussianFilter(arr, stdyrange, stdx=0,
modex='wrap', modey='reflect'):
'''
applies gaussian_filter on input array
but allowing variable ksize in y
stdyrange(int) -> maximum ksize - ksizes will increase from 0 to given value
stdyrange(tuple,list) -> ... | [
"def",
"varYSizeGaussianFilter",
"(",
"arr",
",",
"stdyrange",
",",
"stdx",
"=",
"0",
",",
"modex",
"=",
"'wrap'",
",",
"modey",
"=",
"'reflect'",
")",
":",
"assert",
"arr",
".",
"ndim",
"==",
"2",
",",
"'only works on 2d arrays at the moment'",
"s0",
"=",
... | applies gaussian_filter on input array
but allowing variable ksize in y
stdyrange(int) -> maximum ksize - ksizes will increase from 0 to given value
stdyrange(tuple,list) -> minimum and maximum size as (mn,mx)
stdyrange(np.array) -> all different ksizes in y | [
"applies",
"gaussian_filter",
"on",
"input",
"array",
"but",
"allowing",
"variable",
"ksize",
"in",
"y",
"stdyrange",
"(",
"int",
")",
"-",
">",
"maximum",
"ksize",
"-",
"ksizes",
"will",
"increase",
"from",
"0",
"to",
"given",
"value",
"stdyrange",
"(",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/varYSizeGaussianFilter.py#L9-L50 | train |
radjkarl/imgProcessor | imgProcessor/equations/numbaGaussian2d.py | numbaGaussian2d | def numbaGaussian2d(psf, sy, sx):
'''
2d Gaussian to be used in numba code
'''
ps0, ps1 = psf.shape
c0,c1 = ps0//2, ps1//2
ssx = 2*sx**2
ssy = 2*sy**2
for i in range(ps0):
for j in range(ps1):
psf[i,j]=exp( -( (i-c0)**2/ssy
+(j-c... | python | def numbaGaussian2d(psf, sy, sx):
'''
2d Gaussian to be used in numba code
'''
ps0, ps1 = psf.shape
c0,c1 = ps0//2, ps1//2
ssx = 2*sx**2
ssy = 2*sy**2
for i in range(ps0):
for j in range(ps1):
psf[i,j]=exp( -( (i-c0)**2/ssy
+(j-c... | [
"def",
"numbaGaussian2d",
"(",
"psf",
",",
"sy",
",",
"sx",
")",
":",
"ps0",
",",
"ps1",
"=",
"psf",
".",
"shape",
"c0",
",",
"c1",
"=",
"ps0",
"//",
"2",
",",
"ps1",
"//",
"2",
"ssx",
"=",
"2",
"*",
"sx",
"**",
"2",
"ssy",
"=",
"2",
"*",
... | 2d Gaussian to be used in numba code | [
"2d",
"Gaussian",
"to",
"be",
"used",
"in",
"numba",
"code"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/numbaGaussian2d.py#L10-L22 | train |
radjkarl/imgProcessor | imgProcessor/measure/SNR/estimateBackgroundLevel.py | estimateBackgroundLevel | def estimateBackgroundLevel(img, image_is_artefact_free=False,
min_rel_size=0.05, max_abs_size=11):
'''
estimate background level through finding the most homogeneous area
and take its average
min_size - relative size of the examined area
'''
s0,s1 = i... | python | def estimateBackgroundLevel(img, image_is_artefact_free=False,
min_rel_size=0.05, max_abs_size=11):
'''
estimate background level through finding the most homogeneous area
and take its average
min_size - relative size of the examined area
'''
s0,s1 = i... | [
"def",
"estimateBackgroundLevel",
"(",
"img",
",",
"image_is_artefact_free",
"=",
"False",
",",
"min_rel_size",
"=",
"0.05",
",",
"max_abs_size",
"=",
"11",
")",
":",
"s0",
",",
"s1",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"s",
"=",
"min",
"(",
... | estimate background level through finding the most homogeneous area
and take its average
min_size - relative size of the examined area | [
"estimate",
"background",
"level",
"through",
"finding",
"the",
"most",
"homogeneous",
"area",
"and",
"take",
"its",
"average",
"min_size",
"-",
"relative",
"size",
"of",
"the",
"examined",
"area"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/estimateBackgroundLevel.py#L11-L31 | train |
radjkarl/imgProcessor | imgProcessor/physics/emissivity_vs_angle.py | EL_Si_module | def EL_Si_module():
'''
returns angular dependent EL emissivity of a PV module
calculated of nanmedian(persp-corrected EL module/reference module)
published in K. Bedrich: Quantitative Electroluminescence Measurement on PV devices
PhD Thesis, 2017
'''
arr = np... | python | def EL_Si_module():
'''
returns angular dependent EL emissivity of a PV module
calculated of nanmedian(persp-corrected EL module/reference module)
published in K. Bedrich: Quantitative Electroluminescence Measurement on PV devices
PhD Thesis, 2017
'''
arr = np... | [
"def",
"EL_Si_module",
"(",
")",
":",
"arr",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"2.5",
",",
"1.00281",
"]",
",",
"[",
"7.5",
",",
"1.00238",
"]",
",",
"[",
"12.5",
",",
"1.00174",
"]",
",",
"[",
"17.5",
",",
"1.00204",
"]",
",",
"[",
"22... | returns angular dependent EL emissivity of a PV module
calculated of nanmedian(persp-corrected EL module/reference module)
published in K. Bedrich: Quantitative Electroluminescence Measurement on PV devices
PhD Thesis, 2017 | [
"returns",
"angular",
"dependent",
"EL",
"emissivity",
"of",
"a",
"PV",
"module",
"calculated",
"of",
"nanmedian",
"(",
"persp",
"-",
"corrected",
"EL",
"module",
"/",
"reference",
"module",
")",
"published",
"in",
"K",
".",
"Bedrich",
":",
"Quantitative",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/physics/emissivity_vs_angle.py#L8-L42 | train |
radjkarl/imgProcessor | imgProcessor/physics/emissivity_vs_angle.py | TG_glass | def TG_glass():
'''
reflected temperature for 250DEG Glass
published in IEC 62446-3 TS: Photovoltaic (PV) systems
- Requirements for testing, documentation and maintenance
- Part 3: Outdoor infrared thermography of photovoltaic modules
and plants p Page 12
'''
vals = np.arra... | python | def TG_glass():
'''
reflected temperature for 250DEG Glass
published in IEC 62446-3 TS: Photovoltaic (PV) systems
- Requirements for testing, documentation and maintenance
- Part 3: Outdoor infrared thermography of photovoltaic modules
and plants p Page 12
'''
vals = np.arra... | [
"def",
"TG_glass",
"(",
")",
":",
"vals",
"=",
"np",
".",
"array",
"(",
"[",
"(",
"80",
",",
"0.88",
")",
",",
"(",
"75",
",",
"0.88",
")",
",",
"(",
"70",
",",
"0.88",
")",
",",
"(",
"65",
",",
"0.88",
")",
",",
"(",
"60",
",",
"0.88",
... | reflected temperature for 250DEG Glass
published in IEC 62446-3 TS: Photovoltaic (PV) systems
- Requirements for testing, documentation and maintenance
- Part 3: Outdoor infrared thermography of photovoltaic modules
and plants p Page 12 | [
"reflected",
"temperature",
"for",
"250DEG",
"Glass",
"published",
"in",
"IEC",
"62446",
"-",
"3",
"TS",
":",
"Photovoltaic",
"(",
"PV",
")",
"systems",
"-",
"Requirements",
"for",
"testing",
"documentation",
"and",
"maintenance",
"-",
"Part",
"3",
":",
"Out... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/physics/emissivity_vs_angle.py#L45-L72 | train |
radjkarl/imgProcessor | imgProcessor/camera/flatField/sensitivity.py | sensitivity | def sensitivity(imgs, bg=None):
'''
Extract pixel sensitivity from a set of homogeneously illuminated images
This method is detailed in Section 5 of:
---
K.Bedrich, M.Bokalic et al.:
ELECTROLUMINESCENCE IMAGING OF PV DEVICES:
ADVANCED FLAT FIELD CALIBRATION,2017
---
'''
... | python | def sensitivity(imgs, bg=None):
'''
Extract pixel sensitivity from a set of homogeneously illuminated images
This method is detailed in Section 5 of:
---
K.Bedrich, M.Bokalic et al.:
ELECTROLUMINESCENCE IMAGING OF PV DEVICES:
ADVANCED FLAT FIELD CALIBRATION,2017
---
'''
... | [
"def",
"sensitivity",
"(",
"imgs",
",",
"bg",
"=",
"None",
")",
":",
"bg",
"=",
"getBackground",
"(",
"bg",
")",
"for",
"n",
",",
"i",
"in",
"enumerate",
"(",
"imgs",
")",
":",
"i",
"=",
"imread",
"(",
"i",
",",
"dtype",
"=",
"float",
")",
"i",... | Extract pixel sensitivity from a set of homogeneously illuminated images
This method is detailed in Section 5 of:
---
K.Bedrich, M.Bokalic et al.:
ELECTROLUMINESCENCE IMAGING OF PV DEVICES:
ADVANCED FLAT FIELD CALIBRATION,2017
--- | [
"Extract",
"pixel",
"sensitivity",
"from",
"a",
"set",
"of",
"homogeneously",
"illuminated",
"images",
"This",
"method",
"is",
"detailed",
"in",
"Section",
"5",
"of",
":",
"---",
"K",
".",
"Bedrich",
"M",
".",
"Bokalic",
"et",
"al",
".",
":",
"ELECTROLUMIN... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/sensitivity.py#L7-L30 | train |
radjkarl/imgProcessor | imgProcessor/simulate/navierStokes.py | navierStokes2d | def navierStokes2d(u, v, p, dt, nt, rho, nu,
boundaryConditionUV,
boundardConditionP, nit=100):
'''
solves the Navier-Stokes equation for incompressible flow
one a regular 2d grid
u,v,p --> initial velocity(u,v) and pressure(p) maps
dt --> time s... | python | def navierStokes2d(u, v, p, dt, nt, rho, nu,
boundaryConditionUV,
boundardConditionP, nit=100):
'''
solves the Navier-Stokes equation for incompressible flow
one a regular 2d grid
u,v,p --> initial velocity(u,v) and pressure(p) maps
dt --> time s... | [
"def",
"navierStokes2d",
"(",
"u",
",",
"v",
",",
"p",
",",
"dt",
",",
"nt",
",",
"rho",
",",
"nu",
",",
"boundaryConditionUV",
",",
"boundardConditionP",
",",
"nit",
"=",
"100",
")",
":",
"#next u, v, p maps:\r",
"un",
"=",
"np",
".",
"empty_like",
"(... | solves the Navier-Stokes equation for incompressible flow
one a regular 2d grid
u,v,p --> initial velocity(u,v) and pressure(p) maps
dt --> time step
nt --> number of time steps to caluclate
rho, nu --> material constants
nit --> number of iteration to solve the pre... | [
"solves",
"the",
"Navier",
"-",
"Stokes",
"equation",
"for",
"incompressible",
"flow",
"one",
"a",
"regular",
"2d",
"grid",
"u",
"v",
"p",
"--",
">",
"initial",
"velocity",
"(",
"u",
"v",
")",
"and",
"pressure",
"(",
"p",
")",
"maps",
"dt",
"--",
">"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/simulate/navierStokes.py#L8-L49 | train |
radjkarl/imgProcessor | imgProcessor/simulate/navierStokes.py | shiftImage | def shiftImage(u, v, t, img, interpolation=cv2.INTER_LANCZOS4):
'''
remap an image using velocity field
'''
ny,nx = u.shape
sy, sx = np.mgrid[:float(ny):1,:float(nx):1]
sx += u*t
sy += v*t
return cv2.remap(img.astype(np.float32),
(sx).astype(np.float32),
... | python | def shiftImage(u, v, t, img, interpolation=cv2.INTER_LANCZOS4):
'''
remap an image using velocity field
'''
ny,nx = u.shape
sy, sx = np.mgrid[:float(ny):1,:float(nx):1]
sx += u*t
sy += v*t
return cv2.remap(img.astype(np.float32),
(sx).astype(np.float32),
... | [
"def",
"shiftImage",
"(",
"u",
",",
"v",
",",
"t",
",",
"img",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_LANCZOS4",
")",
":",
"ny",
",",
"nx",
"=",
"u",
".",
"shape",
"sy",
",",
"sx",
"=",
"np",
".",
"mgrid",
"[",
":",
"float",
"(",
"ny",
... | remap an image using velocity field | [
"remap",
"an",
"image",
"using",
"velocity",
"field"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/simulate/navierStokes.py#L52-L62 | train |
radjkarl/imgProcessor | imgProcessor/filters/addNoise.py | addNoise | def addNoise(img, snr=25, rShot=0.5):
'''
adds Gaussian (thermal) and shot noise to [img]
[img] is assumed to be noise free
[rShot] - shot noise ratio relative to all noise
'''
s0, s1 = img.shape[:2]
m = img.mean()
if np.isnan(m):
m = np.nanmean(img)
assert m... | python | def addNoise(img, snr=25, rShot=0.5):
'''
adds Gaussian (thermal) and shot noise to [img]
[img] is assumed to be noise free
[rShot] - shot noise ratio relative to all noise
'''
s0, s1 = img.shape[:2]
m = img.mean()
if np.isnan(m):
m = np.nanmean(img)
assert m... | [
"def",
"addNoise",
"(",
"img",
",",
"snr",
"=",
"25",
",",
"rShot",
"=",
"0.5",
")",
":",
"s0",
",",
"s1",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"m",
"=",
"img",
".",
"mean",
"(",
")",
"if",
"np",
".",
"isnan",
"(",
"m",
")",
":",... | adds Gaussian (thermal) and shot noise to [img]
[img] is assumed to be noise free
[rShot] - shot noise ratio relative to all noise | [
"adds",
"Gaussian",
"(",
"thermal",
")",
"and",
"shot",
"noise",
"to",
"[",
"img",
"]",
"[",
"img",
"]",
"is",
"assumed",
"to",
"be",
"noise",
"free",
"[",
"rShot",
"]",
"-",
"shot",
"noise",
"ratio",
"relative",
"to",
"all",
"noise"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/addNoise.py#L4-L25 | train |
radjkarl/imgProcessor | imgProcessor/filters/coarseMaximum.py | coarseMaximum | def coarseMaximum(arr, shape):
'''
return an array of [shape]
where every cell equals the localised maximum of the given array [arr]
at the same (scalled) position
'''
ss0, ss1 = shape
s0, s1 = arr.shape
pos0 = linspace2(0, s0, ss0, dtype=int)
pos1 = linspace2(0, s1, ss1, ... | python | def coarseMaximum(arr, shape):
'''
return an array of [shape]
where every cell equals the localised maximum of the given array [arr]
at the same (scalled) position
'''
ss0, ss1 = shape
s0, s1 = arr.shape
pos0 = linspace2(0, s0, ss0, dtype=int)
pos1 = linspace2(0, s1, ss1, ... | [
"def",
"coarseMaximum",
"(",
"arr",
",",
"shape",
")",
":",
"ss0",
",",
"ss1",
"=",
"shape",
"s0",
",",
"s1",
"=",
"arr",
".",
"shape",
"pos0",
"=",
"linspace2",
"(",
"0",
",",
"s0",
",",
"ss0",
",",
"dtype",
"=",
"int",
")",
"pos1",
"=",
"lins... | return an array of [shape]
where every cell equals the localised maximum of the given array [arr]
at the same (scalled) position | [
"return",
"an",
"array",
"of",
"[",
"shape",
"]",
"where",
"every",
"cell",
"equals",
"the",
"localised",
"maximum",
"of",
"the",
"given",
"array",
"[",
"arr",
"]",
"at",
"the",
"same",
"(",
"scalled",
")",
"position"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/coarseMaximum.py#L8-L25 | train |
radjkarl/imgProcessor | imgProcessor/equations/angleOfView.py | angleOfView | def angleOfView(XY, shape=None, a=None, f=None, D=None, center=None):
'''
Another vignetting equation from:
M. Koentges, M. Siebert, and D. Hinken, "Quantitative analysis of PV-modules by electroluminescence images for quality control"
2009
f --> Focal length
D --> Diameter of the aper... | python | def angleOfView(XY, shape=None, a=None, f=None, D=None, center=None):
'''
Another vignetting equation from:
M. Koentges, M. Siebert, and D. Hinken, "Quantitative analysis of PV-modules by electroluminescence images for quality control"
2009
f --> Focal length
D --> Diameter of the aper... | [
"def",
"angleOfView",
"(",
"XY",
",",
"shape",
"=",
"None",
",",
"a",
"=",
"None",
",",
"f",
"=",
"None",
",",
"D",
"=",
"None",
",",
"center",
"=",
"None",
")",
":",
"if",
"a",
"is",
"None",
":",
"assert",
"f",
"is",
"not",
"None",
"and",
"D... | Another vignetting equation from:
M. Koentges, M. Siebert, and D. Hinken, "Quantitative analysis of PV-modules by electroluminescence images for quality control"
2009
f --> Focal length
D --> Diameter of the aperture
BOTH, D AND f NEED TO HAVE SAME UNIT [PX, mm ...]
a --> Angular a... | [
"Another",
"vignetting",
"equation",
"from",
":",
"M",
".",
"Koentges",
"M",
".",
"Siebert",
"and",
"D",
".",
"Hinken",
"Quantitative",
"analysis",
"of",
"PV",
"-",
"modules",
"by",
"electroluminescence",
"images",
"for",
"quality",
"control",
"2009",
"f",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/angleOfView.py#L12-L40 | train |
radjkarl/imgProcessor | imgProcessor/equations/angleOfView.py | angleOfView2 | def angleOfView2(x,y, b, x0=None,y0=None):
'''
Corrected AngleOfView equation by Koentges (via mail from 14/02/2017)
b --> distance between the camera and the module in m
x0 --> viewable with in the module plane of the camera in m
y0 --> viewable height in the module plane of the camera in m
... | python | def angleOfView2(x,y, b, x0=None,y0=None):
'''
Corrected AngleOfView equation by Koentges (via mail from 14/02/2017)
b --> distance between the camera and the module in m
x0 --> viewable with in the module plane of the camera in m
y0 --> viewable height in the module plane of the camera in m
... | [
"def",
"angleOfView2",
"(",
"x",
",",
"y",
",",
"b",
",",
"x0",
"=",
"None",
",",
"y0",
"=",
"None",
")",
":",
"if",
"x0",
"is",
"None",
":",
"x0",
"=",
"x",
"[",
"-",
"1",
",",
"-",
"1",
"]",
"if",
"y0",
"is",
"None",
":",
"y0",
"=",
"... | Corrected AngleOfView equation by Koentges (via mail from 14/02/2017)
b --> distance between the camera and the module in m
x0 --> viewable with in the module plane of the camera in m
y0 --> viewable height in the module plane of the camera in m
x,y --> pixel position [m] from top left | [
"Corrected",
"AngleOfView",
"equation",
"by",
"Koentges",
"(",
"via",
"mail",
"from",
"14",
"/",
"02",
"/",
"2017",
")",
"b",
"--",
">",
"distance",
"between",
"the",
"camera",
"and",
"the",
"module",
"in",
"m",
"x0",
"--",
">",
"viewable",
"with",
"in... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/angleOfView.py#L43-L56 | train |
radjkarl/imgProcessor | imgProcessor/utils/gridLinesFromVertices.py | gridLinesFromVertices | def gridLinesFromVertices(edges, nCells, subgrid=None, dtype=float):
"""
###TODO REDO TXT
OPTIONAL:
subgrid = ([x],[y]) --> relative positions
e.g. subgrid = ( (0.3,0.7), () )
--> two subgrid lines in x - nothing in y
Returns:
horiz,vert -> arrays of (x,y) ... | python | def gridLinesFromVertices(edges, nCells, subgrid=None, dtype=float):
"""
###TODO REDO TXT
OPTIONAL:
subgrid = ([x],[y]) --> relative positions
e.g. subgrid = ( (0.3,0.7), () )
--> two subgrid lines in x - nothing in y
Returns:
horiz,vert -> arrays of (x,y) ... | [
"def",
"gridLinesFromVertices",
"(",
"edges",
",",
"nCells",
",",
"subgrid",
"=",
"None",
",",
"dtype",
"=",
"float",
")",
":",
"nx",
",",
"ny",
"=",
"nCells",
"y",
",",
"x",
"=",
"np",
".",
"mgrid",
"[",
"0.",
":",
"ny",
"+",
"1",
",",
"0.",
"... | ###TODO REDO TXT
OPTIONAL:
subgrid = ([x],[y]) --> relative positions
e.g. subgrid = ( (0.3,0.7), () )
--> two subgrid lines in x - nothing in y
Returns:
horiz,vert -> arrays of (x,y) poly-lines
if subgrid != None, Returns:
horiz,vert, subhoriz,... | [
"###TODO",
"REDO",
"TXT",
"OPTIONAL",
":",
"subgrid",
"=",
"(",
"[",
"x",
"]",
"[",
"y",
"]",
")",
"--",
">",
"relative",
"positions",
"e",
".",
"g",
".",
"subgrid",
"=",
"(",
"(",
"0",
".",
"3",
"0",
".",
"7",
")",
"()",
")",
"--",
">",
"t... | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/gridLinesFromVertices.py#L39-L107 | train |
radjkarl/imgProcessor | imgProcessor/measure/sharpness/_base.py | SharpnessBase.MTF50 | def MTF50(self, MTFx,MTFy):
'''
return object resolution as [line pairs/mm]
where MTF=50%
see http://www.imatest.com/docs/sharpness/
'''
if self.mtf_x is None:
self.MTF()
f = UnivariateSpline(self.mtf_x, self.mtf_y-0.5)
r... | python | def MTF50(self, MTFx,MTFy):
'''
return object resolution as [line pairs/mm]
where MTF=50%
see http://www.imatest.com/docs/sharpness/
'''
if self.mtf_x is None:
self.MTF()
f = UnivariateSpline(self.mtf_x, self.mtf_y-0.5)
r... | [
"def",
"MTF50",
"(",
"self",
",",
"MTFx",
",",
"MTFy",
")",
":",
"if",
"self",
".",
"mtf_x",
"is",
"None",
":",
"self",
".",
"MTF",
"(",
")",
"f",
"=",
"UnivariateSpline",
"(",
"self",
".",
"mtf_x",
",",
"self",
".",
"mtf_y",
"-",
"0.5",
")",
"... | return object resolution as [line pairs/mm]
where MTF=50%
see http://www.imatest.com/docs/sharpness/ | [
"return",
"object",
"resolution",
"as",
"[",
"line",
"pairs",
"/",
"mm",
"]",
"where",
"MTF",
"=",
"50%",
"see",
"http",
":",
"//",
"www",
".",
"imatest",
".",
"com",
"/",
"docs",
"/",
"sharpness",
"/"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L21-L30 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.