partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | ObjectVignettingSeparation.addImg | 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
... | imgProcessor/camera/flatField/vignettingFromRandomSteps.py | 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
"""
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... | [
"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",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L114-L167 | [
"def",
"addImg",
"(",
"self",
",",
"img",
",",
"maxShear",
"=",
"0.015",
",",
"maxRot",
"=",
"100",
",",
"minMatches",
"=",
"12",
",",
"borderWidth",
"=",
"3",
")",
":",
"# borderWidth=100\r",
"try",
":",
"fit",
",",
"img",
",",
"H",
",",
"H_inv",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | ObjectVignettingSeparation.error | calculate the standard deviation of all fitted images,
averaged to a grid | imgProcessor/camera/flatField/vignettingFromRandomSteps.py | 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):
'''
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... | [
"calculate",
"the",
"standard",
"deviation",
"of",
"all",
"fitted",
"images",
"averaged",
"to",
"a",
"grid"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L169-L197 | [
"def",
"error",
"(",
"self",
",",
"nCells",
"=",
"15",
")",
":",
"s0",
",",
"s1",
"=",
"self",
".",
"fits",
"[",
"0",
"]",
".",
"shape",
"aR",
"=",
"s0",
"/",
"s1",
"if",
"aR",
">",
"1",
":",
"ss0",
"=",
"int",
"(",
"nCells",
")",
"ss1",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | ObjectVignettingSeparation._fitImg | fit perspective and size of the input image to the reference image | imgProcessor/camera/flatField/vignettingFromRandomSteps.py | 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):
'''
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... | [
"fit",
"perspective",
"and",
"size",
"of",
"the",
"input",
"image",
"to",
"the",
"reference",
"image"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L294-L310 | [
"def",
"_fitImg",
"(",
"self",
",",
"img",
")",
":",
"img",
"=",
"imread",
"(",
"img",
",",
"'gray'",
")",
"if",
"self",
".",
"bg",
"is",
"not",
"None",
":",
"img",
"=",
"cv2",
".",
"subtract",
"(",
"img",
",",
"self",
".",
"bg",
")",
"if",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | ObjectVignettingSeparation._findObject | Create a bounding box around the object within an image | imgProcessor/camera/flatField/vignettingFromRandomSteps.py | 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):
'''
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 ... | [
"Create",
"a",
"bounding",
"box",
"around",
"the",
"object",
"within",
"an",
"image"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromRandomSteps.py#L312-L321 | [
"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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | filterVerticalLines | Remove vertical lines in boolean array if linelength >=min_line_length | imgProcessor/filters/filterVerticalLines.py | 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):
"""
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 ... | [
"Remove",
"vertical",
"lines",
"in",
"boolean",
"array",
"if",
"linelength",
">",
"=",
"min_line_length"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/filterVerticalLines.py#L4-L23 | [
"def",
"filterVerticalLines",
"(",
"arr",
",",
"min_line_length",
"=",
"4",
")",
":",
"gy",
"=",
"arr",
".",
"shape",
"[",
"0",
"]",
"gx",
"=",
"arr",
".",
"shape",
"[",
"1",
"]",
"mn",
"=",
"min_line_length",
"-",
"1",
"for",
"i",
"in",
"range",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | vignetting | 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... | imgProcessor/equations/vignetting.py | 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):
'''
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... | [
"Vignetting",
"equation",
"using",
"the",
"KANG",
"-",
"WEISS",
"-",
"MODEL",
"see",
"http",
":",
"//",
"research",
".",
"microsoft",
".",
"com",
"/",
"en",
"-",
"us",
"/",
"um",
"/",
"people",
"/",
"sbkang",
"/",
"publications",
"/",
"eccv00",
".",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/vignetting.py#L9-L37 | [
"def",
"vignetting",
"(",
"xy",
",",
"f",
"=",
"100",
",",
"alpha",
"=",
"0",
",",
"rot",
"=",
"0",
",",
"tilt",
"=",
"0",
",",
"cx",
"=",
"50",
",",
"cy",
"=",
"50",
")",
":",
"x",
",",
"y",
"=",
"xy",
"# distance to image center:\r",
"dist",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | tiltFactor | 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] | imgProcessor/equations/vignetting.py | 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):
'''
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) *... | [
"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... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/vignetting.py#L40-L52 | [
"def",
"tiltFactor",
"(",
"xy",
",",
"f",
",",
"tilt",
",",
"rot",
",",
"center",
"=",
"None",
")",
":",
"x",
",",
"y",
"=",
"xy",
"arr",
"=",
"np",
".",
"cos",
"(",
"tilt",
")",
"*",
"(",
"1",
"+",
"(",
"np",
".",
"tan",
"(",
"tilt",
")"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | imgAverage | returns an image average
works on many, also unloaded images
minimises RAM usage | imgProcessor/transform/imgAverage.py | 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):
'''
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... | [
"returns",
"an",
"image",
"average",
"works",
"on",
"many",
"also",
"unloaded",
"images",
"minimises",
"RAM",
"usage"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/imgAverage.py#L7-L22 | [
"def",
"imgAverage",
"(",
"images",
",",
"copy",
"=",
"True",
")",
":",
"i0",
"=",
"images",
"[",
"0",
"]",
"out",
"=",
"imread",
"(",
"i0",
",",
"dtype",
"=",
"'float'",
")",
"if",
"copy",
"and",
"id",
"(",
"i0",
")",
"==",
"id",
"(",
"out",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | offsetMeshgrid | 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 [... | imgProcessor/interpolate/offsetMeshgrid.py | 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):
'''
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... | [
"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",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/offsetMeshgrid.py#L5-L27 | [
"def",
"offsetMeshgrid",
"(",
"offset",
",",
"grid",
",",
"shape",
")",
":",
"g0",
",",
"g1",
"=",
"grid",
"s0",
",",
"s1",
"=",
"shape",
"o0",
",",
"o1",
"=",
"offset",
"#rescale to small grid:\r",
"o0",
"=",
"-",
"o0",
"/",
"s0",
"*",
"(",
"g0",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | poisson | Poisson function
a -> height of the curve's peak
b -> position of the center of the peak
c -> standard deviation
d -> offset | imgProcessor/equations/poisson.py | 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):
'''
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 * ((... | [
"Poisson",
"function",
"a",
"-",
">",
"height",
"of",
"the",
"curve",
"s",
"peak",
"b",
"-",
">",
"position",
"of",
"the",
"center",
"of",
"the",
"peak",
"c",
"-",
">",
"standard",
"deviation",
"d",
"-",
">",
"offset"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/poisson.py#L4-L15 | [
"def",
"poisson",
"(",
"x",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
"=",
"0",
")",
":",
"from",
"scipy",
".",
"misc",
"import",
"factorial",
"#save startup time\r",
"lamb",
"=",
"1",
"X",
"=",
"(",
"x",
"/",
"(",
"2",
"*",
"c",
")",
")",
".",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | rotate | angle [deg] | imgProcessor/transform/rotate.py | 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):
'''
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... | [
"angle",
"[",
"deg",
"]"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/rotate.py#L8-L19 | [
"def",
"rotate",
"(",
"image",
",",
"angle",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_CUBIC",
",",
"borderMode",
"=",
"cv2",
".",
"BORDER_REFLECT",
",",
"borderValue",
"=",
"0",
")",
":",
"s0",
",",
"s1",
"=",
"image",
".",
"shape",
"image_center",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | adjustUncertToExposureTime | 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... | imgProcessor/uncertainty/adjustUncertToExposureTime.py | 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):
'''
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... | [
"Adjust",
"image",
"uncertainty",
"(",
"measured",
"at",
"exposure",
"time",
"t0",
")",
"to",
"new",
"exposure",
"time",
"facExpTime",
"--",
">",
"new",
"exp",
".",
"time",
"/",
"reference",
"exp",
".",
"time",
"=",
"(",
"t",
"/",
"t0",
")",
"uncertMap... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/adjustUncertToExposureTime.py#L10-L59 | [
"def",
"adjustUncertToExposureTime",
"(",
"facExpTime",
",",
"uncertMap",
",",
"evtLenMap",
")",
":",
"#fit parameters, obtained from ####[simulateUncertDependencyOnExpTime]\r",
"params",
"=",
"np",
".",
"array",
"(",
"#a facExpTime f_0 f_inf ... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | gaussian | a -> height of the curve's peak
b -> position of the center of the peak
c -> standard deviation or Gaussian RMS width
d -> offset | imgProcessor/equations/gaussian.py | 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):
'''
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 | [
"a",
"-",
">",
"height",
"of",
"the",
"curve",
"s",
"peak",
"b",
"-",
">",
"position",
"of",
"the",
"center",
"of",
"the",
"peak",
"c",
"-",
">",
"standard",
"deviation",
"or",
"Gaussian",
"RMS",
"width",
"d",
"-",
">",
"offset"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/gaussian.py#L6-L13 | [
"def",
"gaussian",
"(",
"x",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
"=",
"0",
")",
":",
"return",
"a",
"*",
"np",
".",
"exp",
"(",
"-",
"(",
"(",
"(",
"x",
"-",
"b",
")",
"**",
"2",
")",
"/",
"(",
"2",
"*",
"(",
"c",
"**",
"2",
")"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | videoWrite | TODO | imgProcessor/interpolate/videoWrite.py | 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):
'''
TODO
'''
frames = int(frames)
if annotate_names is not None:
assert len(annotate_names) == len(imgs)
if levels is None:
if i... | [
"TODO"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/videoWrite.py#L14-L81 | [
"def",
"videoWrite",
"(",
"path",
",",
"imgs",
",",
"levels",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"frames",
"=",
"15",
",",
"annotate_names",
"=",
"None",
",",
"lut",
"=",
"None",
",",
"updateFn",
"=",
"None",
")",
":",
"frames",
"=",
"int... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | imread | dtype = 'noUint', uint8, float, 'float', ... | imgProcessor/imgIO.py | 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):
'''
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... | [
"dtype",
"=",
"noUint",
"uint8",
"float",
"float",
"..."
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgIO.py#L39-L73 | [
"def",
"imread",
"(",
"img",
",",
"color",
"=",
"None",
",",
"dtype",
"=",
"None",
")",
":",
"COLOR2CV",
"=",
"{",
"'gray'",
":",
"cv2",
".",
"IMREAD_GRAYSCALE",
",",
"'all'",
":",
"cv2",
".",
"IMREAD_COLOR",
",",
"None",
":",
"cv2",
".",
"IMREAD_ANY... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SharpnessfromPointSources.addImg | img - background, flat field, ste corrected image
roi - [(x1,y1),...,(x4,y4)] - boundaries where points are | imgProcessor/measure/sharpness/SharpnessfromPoints.py | 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):
'''
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... | [
"img",
"-",
"background",
"flat",
"field",
"ste",
"corrected",
"image",
"roi",
"-",
"[",
"(",
"x1",
"y1",
")",
"...",
"(",
"x4",
"y4",
")",
"]",
"-",
"boundaries",
"where",
"points",
"are"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/SharpnessfromPoints.py#L78-L220 | [
"def",
"addImg",
"(",
"self",
",",
"img",
",",
"roi",
"=",
"None",
")",
":",
"self",
".",
"img",
"=",
"imread",
"(",
"img",
",",
"'gray'",
")",
"s0",
",",
"s1",
"=",
"self",
".",
"img",
".",
"shape",
"if",
"roi",
"is",
"None",
":",
"roi",
"="... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | interpolate2dStructuredFastIDW | 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 ... | imgProcessor/interpolate/interpolate2dStructuredFastIDW.py | 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):
'''
FASTER IMPLEMENTATION OF interpolate2dStructuredIDW
replace all values in [grid] indicated by [mask]
with the inverse distance weighted interpolation of all values within
px... | [
"FASTER",
"IMPLEMENTATION",
"OF",
"interpolate2dStructuredIDW",
"replace",
"all",
"values",
"in",
"[",
"grid",
"]",
"indicated",
"by",
"[",
"mask",
"]",
"with",
"the",
"inverse",
"distance",
"weighted",
"interpolation",
"of",
"all",
"values",
"within",
"px",
"+"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredFastIDW.py#L9-L26 | [
"def",
"interpolate2dStructuredFastIDW",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
",",
"minnvals",
"=",
"5",
")",
":",
"indices",
",",
"dist",
"=",
"growPositions",
"(",
"kernel",
")",
"weights",
"=",
"1",
"/",
"dist"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | linearBlend | 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 | imgProcessor/transform/linearBlend.py | 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):
'''
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 ... | [
"Stitch",
"2",
"images",
"vertically",
"together",
".",
"Smooth",
"the",
"overlap",
"area",
"of",
"both",
"images",
"with",
"a",
"linear",
"fade",
"from",
"img1",
"to",
"img2"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/linearBlend.py#L7-L55 | [
"def",
"linearBlend",
"(",
"img1",
",",
"img2",
",",
"overlap",
",",
"backgroundColor",
"=",
"None",
")",
":",
"(",
"sizex",
",",
"sizey",
")",
"=",
"img1",
".",
"shape",
"[",
":",
"2",
"]",
"overlapping",
"=",
"True",
"if",
"overlap",
"<",
"0",
":... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | interpolate2dStructuredPointSpreadIDW | 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
... | imgProcessor/interpolate/interpolate2dStructuredPointSpreadIDW.py | 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):
'''
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... | [
"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",... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredPointSpreadIDW.py#L7-L28 | [
"def",
"interpolate2dStructuredPointSpreadIDW",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
",",
"maxIter",
"=",
"1e5",
",",
"copy",
"=",
"True",
")",
":",
"assert",
"grid",
".",
"shape",
"==",
"mask",
".",
"shape",
",",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SNRaverage | 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 ... | imgProcessor/measure/SNR/SNRaverage.py | 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):
'''
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
... | [
"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",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNRaverage.py#L10-L58 | [
"def",
"SNRaverage",
"(",
"snr",
",",
"method",
"=",
"'average'",
",",
"excludeBackground",
"=",
"True",
",",
"checkBackground",
"=",
"True",
",",
"backgroundLevel",
"=",
"None",
")",
":",
"if",
"excludeBackground",
":",
"# get background level\r",
"if",
"backgr... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | maskedConvolve | same as scipy.ndimage.convolve but is only executed on mask==True
... which should speed up everything | imgProcessor/filters/maskedConvolve.py | 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'):
'''
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)
... | [
"same",
"as",
"scipy",
".",
"ndimage",
".",
"convolve",
"but",
"is",
"only",
"executed",
"on",
"mask",
"==",
"True",
"...",
"which",
"should",
"speed",
"up",
"everything"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/maskedConvolve.py#L13-L21 | [
"def",
"maskedConvolve",
"(",
"arr",
",",
"kernel",
",",
"mask",
",",
"mode",
"=",
"'reflect'",
")",
":",
"arr2",
"=",
"extendArrayForConvolution",
"(",
"arr",
",",
"kernel",
".",
"shape",
",",
"modex",
"=",
"mode",
",",
"modey",
"=",
"mode",
")",
"pri... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SNR | 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) | imgProcessor/measure/SNR/SNR.py | 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):
'''
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... | [
"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",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNR.py#L21-L79 | [
"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",
"=",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | sortCorners | 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 | imgProcessor/utils/sortCorners.py | 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):
'''
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... | [
"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",
"(",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/sortCorners.py#L8-L50 | [
"def",
"sortCorners",
"(",
"corners",
")",
":",
"corners",
"=",
"np",
".",
"asarray",
"(",
"corners",
")",
"# bring edges in order:\r",
"corners2",
"=",
"corners",
"[",
"ConvexHull",
"(",
"corners",
")",
".",
"vertices",
"]",
"if",
"len",
"(",
"corners2",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | closestDirectDistance | return an array with contains the closest distance to the next positive
value given in arr within a given kernel size | imgProcessor/render/closestDirectDistance.py | 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):
'''
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 | [
"return",
"an",
"array",
"with",
"contains",
"the",
"closest",
"distance",
"to",
"the",
"next",
"positive",
"value",
"given",
"in",
"arr",
"within",
"a",
"given",
"kernel",
"size"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestDirectDistance.py#L6-L14 | [
"def",
"closestDirectDistance",
"(",
"arr",
",",
"ksize",
"=",
"30",
",",
"dtype",
"=",
"np",
".",
"uint16",
")",
":",
"out",
"=",
"np",
".",
"zeros_like",
"(",
"arr",
",",
"dtype",
"=",
"dtype",
")",
"_calc",
"(",
"out",
",",
"arr",
",",
"ksize",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | closestConnectedDistance | 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 ... | imgProcessor/render/closestConnectedDistance.py | 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):
'''
returns an array with contains the closest distance from every pixel
the next position wher... | [
"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... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestConnectedDistance.py#L14-L77 | [
"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",
">=",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | _grow | 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... | imgProcessor/render/closestConnectedDistance.py | 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):
'''
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... | [
"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",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/render/closestConnectedDistance.py#L100-L166 | [
"def",
"_grow",
"(",
"growth",
",",
"walls",
",",
"target",
",",
"i",
",",
"j",
",",
"steps",
",",
"new_steps",
",",
"res",
")",
":",
"# clean array:\r",
"growth",
"[",
":",
"]",
"=",
"0",
"if",
"target",
"[",
"i",
",",
"j",
"]",
":",
"# pixel is... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | polylinesFromBinImage | 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:
-------------
... | imgProcessor/features/polylinesFromBinImage.py | 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 conto... | [
"return",
"a",
"list",
"of",
"arrays",
"of",
"un",
"-",
"branching",
"contours",
"img",
"-",
">",
"(",
"boolean",
")",
"array",
"optional",
":",
"---------",
"minimum_cluster_size",
"-",
">",
"minimum",
"number",
"of",
"pixels",
"connected",
"together",
"to"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/polylinesFromBinImage.py#L14-L73 | [
"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",
")",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | cdf | Return the cumulative density function of a given array or
its intensity at a given position (0-1) | imgProcessor/utils/cdf.py | 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):
'''
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... | [
"Return",
"the",
"cumulative",
"density",
"function",
"of",
"a",
"given",
"array",
"or",
"its",
"intensity",
"at",
"a",
"given",
"position",
"(",
"0",
"-",
"1",
")"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/cdf.py#L7-L20 | [
"def",
"cdf",
"(",
"arr",
",",
"pos",
"=",
"None",
")",
":",
"r",
"=",
"(",
"arr",
".",
"min",
"(",
")",
",",
"arr",
".",
"max",
"(",
")",
")",
"hist",
",",
"bin_edges",
"=",
"np",
".",
"histogram",
"(",
"arr",
",",
"bins",
"=",
"2",
"*",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | subCell2DGenerator | 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... | imgProcessor/array/subCell2D.py | 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):
'''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... | [
"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",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L5-L29 | [
"def",
"subCell2DGenerator",
"(",
"arr",
",",
"shape",
",",
"d01",
"=",
"None",
",",
"p01",
"=",
"None",
")",
":",
"for",
"i",
",",
"j",
",",
"s0",
",",
"s1",
"in",
"subCell2DSlices",
"(",
"arr",
",",
"shape",
",",
"d01",
",",
"p01",
")",
":",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | subCell2DSlices | 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... | imgProcessor/array/subCell2D.py | 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):
'''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:
... | [
"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",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L32-L71 | [
"def",
"subCell2DSlices",
"(",
"arr",
",",
"shape",
",",
"d01",
"=",
"None",
",",
"p01",
"=",
"None",
")",
":",
"if",
"p01",
"is",
"not",
"None",
":",
"yinit",
",",
"xinit",
"=",
"p01",
"else",
":",
"xinit",
",",
"yinit",
"=",
"0",
",",
"0",
"x... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | subCell2DCoords | Same as subCell2DSlices but returning coordinates
Example:
g = subCell2DCoords(arr, shape)
for x, y in g:
plt.plot(x, y) | imgProcessor/array/subCell2D.py | 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):
'''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... | [
"Same",
"as",
"subCell2DSlices",
"but",
"returning",
"coordinates",
"Example",
":",
"g",
"=",
"subCell2DCoords",
"(",
"arr",
"shape",
")",
"for",
"x",
"y",
"in",
"g",
":",
"plt",
".",
"plot",
"(",
"x",
"y",
")"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L74-L84 | [
"def",
"subCell2DCoords",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"_",
",",
"_",
",",
"s0",
",",
"s1",
"in",
"subCell2DSlices",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"yield",
"(",
"(",
"s1",
".",
"start",
",",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | subCell2DFnArray | 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 ... | imgProcessor/array/subCell2D.py | 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):
'''
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:
... | [
"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",
":",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/array/subCell2D.py#L87-L107 | [
"def",
"subCell2DFnArray",
"(",
"arr",
",",
"fn",
",",
"shape",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"sh",
"=",
"list",
"(",
"arr",
".",
"shape",
")",
"sh",
"[",
":",
"2",
"]",
"=",
"shape",
"out",
"=",
"np",
".",
"em... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | defocusThroughDepth | 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
... | imgProcessor/equations/defocusThroughDepth.py | 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):
'''
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... | [
"return",
"the",
"defocus",
"(",
"mm",
"std",
")",
"through",
"DOF",
"u",
"-",
">",
"scene",
"point",
"(",
"depth",
"value",
")",
"uf",
"-",
">",
"in",
"-",
"focus",
"position",
"(",
"the",
"distance",
"at",
"which",
"the",
"scene",
"point",
"should"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/defocusThroughDepth.py#L4-L22 | [
"def",
"defocusThroughDepth",
"(",
"u",
",",
"uf",
",",
"f",
",",
"fn",
",",
"k",
"=",
"2.355",
")",
":",
"# A = f/fn \r",
"return",
"(",
"k",
"/",
"fn",
")",
"*",
"(",
"f",
"**",
"2",
"*",
"abs",
"(",
"u",
"-",
"uf",
")",
")",
"/",
"(",
"u... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | extendArrayForConvolution | 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 | imgProcessor/filters/_extendArrayForConvolution.py | 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'):
'''
extends a given array right right border handling
for convolution
-->in opposite to skimage and skipy this function
allows to chose different mode = ('ref... | [
"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",
")",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/_extendArrayForConvolution.py#L5-L97 | [
"def",
"extendArrayForConvolution",
"(",
"arr",
",",
"kernelXY",
",",
"modex",
"=",
"'reflect'",
",",
"modey",
"=",
"'reflect'",
")",
":",
"(",
"kx",
",",
"ky",
")",
"=",
"kernelXY",
"kx",
"//=",
"2",
"ky",
"//=",
"2",
"#indexing 0:-0 leads to empty arrays a... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.calibrate | sensorSize_mm - (width, height) [mm] Physical size of the sensor | imgProcessor/camera/LensDistortion.py | 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
'''
self._coeffs = {}
self.opts = {'fo... | [
"sensorSize_mm",
"-",
"(",
"width",
"height",
")",
"[",
"mm",
"]",
"Physical",
"size",
"of",
"the",
"sensor"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L35-L80 | [
"def",
"calibrate",
"(",
"self",
",",
"board_size",
"=",
"(",
"8",
",",
"6",
")",
",",
"method",
"=",
"'Chessboard'",
",",
"images",
"=",
"[",
"]",
",",
"max_images",
"=",
"100",
",",
"sensorSize_mm",
"=",
"None",
",",
"detect_sensible",
"=",
"True",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.addPoints | add corner points directly instead of extracting them from
image
points = ( (0,1), (...),... ) [x,y] | imgProcessor/camera/LensDistortion.py | 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):
'''
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:
... | [
"add",
"corner",
"points",
"directly",
"instead",
"of",
"extracting",
"them",
"from",
"image",
"points",
"=",
"(",
"(",
"0",
"1",
")",
"(",
"...",
")",
"...",
")",
"[",
"x",
"y",
"]"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L91-L106 | [
"def",
"addPoints",
"(",
"self",
",",
"points",
",",
"board_size",
"=",
"None",
")",
":",
"self",
".",
"opts",
"[",
"'foundPattern'",
"]",
".",
"append",
"(",
"True",
")",
"self",
".",
"findCount",
"+=",
"1",
"if",
"board_size",
"is",
"not",
"None",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.setImgShape | 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 | imgProcessor/camera/LensDistortion.py | 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):
'''
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... | [
"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... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L108-L118 | [
"def",
"setImgShape",
"(",
"self",
",",
"shape",
")",
":",
"self",
".",
"img",
"=",
"type",
"(",
"'Dummy'",
",",
"(",
"object",
",",
")",
",",
"{",
"}",
")",
"# if imgProcessor.ARRAYS_ORDER_IS_XY:\r",
"# self.img.shape = shape[::-1]\r",
"# ... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.addImgStream | add images using a continous stream
- stop when max number of images is reached | imgProcessor/camera/LensDistortion.py | 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):
'''
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) | [
"add",
"images",
"using",
"a",
"continous",
"stream",
"-",
"stop",
"when",
"max",
"number",
"of",
"images",
"is",
"reached"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L120-L127 | [
"def",
"addImgStream",
"(",
"self",
",",
"img",
")",
":",
"if",
"self",
".",
"findCount",
">",
"self",
".",
"max_images",
":",
"raise",
"EnoughImages",
"(",
"'have enough images'",
")",
"return",
"self",
".",
"addImg",
"(",
"img",
")"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.addImg | add one chessboard image for detection lens distortion | imgProcessor/camera/LensDistortion.py | 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):
'''
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)
... | [
"add",
"one",
"chessboard",
"image",
"for",
"detection",
"lens",
"distortion"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L129-L144 | [
"def",
"addImg",
"(",
"self",
",",
"img",
")",
":",
"# self.opts['imgs'].append(img)\r",
"self",
".",
"img",
"=",
"imread",
"(",
"img",
",",
"'gray'",
",",
"'uint8'",
")",
"didFindCorners",
",",
"corners",
"=",
"self",
".",
"method",
"(",
")",
"self",
".... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.getCoeffStr | get the distortion coeffs in a formated string | imgProcessor/camera/LensDistortion.py | 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):
'''
get the distortion coeffs in a formated string
'''
txt = ''
for key, val in self.coeffs.items():
txt += '%s = %s\n' % (key, val)
return txt | [
"get",
"the",
"distortion",
"coeffs",
"in",
"a",
"formated",
"string"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L177-L184 | [
"def",
"getCoeffStr",
"(",
"self",
")",
":",
"txt",
"=",
"''",
"for",
"key",
",",
"val",
"in",
"self",
".",
"coeffs",
".",
"items",
"(",
")",
":",
"txt",
"+=",
"'%s = %s\\n'",
"%",
"(",
"key",
",",
"val",
")",
"return",
"txt"
] | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.drawChessboard | 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 | imgProcessor/camera/LensDistortion.py | 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):
'''
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... | [
"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"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L186-L212 | [
"def",
"drawChessboard",
"(",
"self",
",",
"img",
"=",
"None",
")",
":",
"assert",
"self",
".",
"findCount",
">",
"0",
",",
"'cannot draw chessboard if nothing found'",
"if",
"img",
"is",
"None",
":",
"img",
"=",
"self",
".",
"img",
"elif",
"isinstance",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.writeToFile | write the distortion coeffs to file
saveOpts --> Whether so save calibration options (and not just results) | imgProcessor/camera/LensDistortion.py | 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):
'''
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... | [
"write",
"the",
"distortion",
"coeffs",
"to",
"file",
"saveOpts",
"--",
">",
"Whether",
"so",
"save",
"calibration",
"options",
"(",
"and",
"not",
"just",
"results",
")"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L258-L275 | [
"def",
"writeToFile",
"(",
"self",
",",
"filename",
",",
"saveOpts",
"=",
"False",
")",
":",
"try",
":",
"if",
"not",
"filename",
".",
"endswith",
"(",
"'.%s'",
"%",
"self",
".",
"ftype",
")",
":",
"filename",
"+=",
"'.%s'",
"%",
"self",
".",
"ftype"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.readFromFile | read the distortion coeffs from file | imgProcessor/camera/LensDistortion.py | 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):
'''
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... | [
"read",
"the",
"distortion",
"coeffs",
"from",
"file"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L277-L291 | [
"def",
"readFromFile",
"(",
"self",
",",
"filename",
")",
":",
"s",
"=",
"dict",
"(",
"np",
".",
"load",
"(",
"filename",
")",
")",
"try",
":",
"self",
".",
"coeffs",
"=",
"s",
"[",
"'coeffs'",
"]",
"[",
"(",
")",
"]",
"except",
"KeyError",
":",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.undistortPoints | points --> list of (x,y) coordinates | imgProcessor/camera/LensDistortion.py | 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):
'''
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:
... | [
"points",
"--",
">",
"list",
"of",
"(",
"x",
"y",
")",
"coordinates"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L293-L314 | [
"def",
"undistortPoints",
"(",
"self",
",",
"points",
",",
"keepSize",
"=",
"False",
")",
":",
"s",
"=",
"self",
".",
"img",
".",
"shape",
"cam",
"=",
"self",
".",
"coeffs",
"[",
"'cameraMatrix'",
"]",
"d",
"=",
"self",
".",
"coeffs",
"[",
"'distorti... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.correct | remove lens distortion from given image | imgProcessor/camera/LensDistortion.py | 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):
'''
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,
... | [
"remove",
"lens",
"distortion",
"from",
"given",
"image"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L316-L330 | [
"def",
"correct",
"(",
"self",
",",
"image",
",",
"keepSize",
"=",
"False",
",",
"borderValue",
"=",
"0",
")",
":",
"image",
"=",
"imread",
"(",
"image",
")",
"(",
"h",
",",
"w",
")",
"=",
"image",
".",
"shape",
"[",
":",
"2",
"]",
"mapx",
",",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.distortImage | opposite of 'correct' | imgProcessor/camera/LensDistortion.py | 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):
'''
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,
... | [
"opposite",
"of",
"correct"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L332-L340 | [
"def",
"distortImage",
"(",
"self",
",",
"image",
")",
":",
"image",
"=",
"imread",
"(",
"image",
")",
"(",
"imgHeight",
",",
"imgWidth",
")",
"=",
"image",
".",
"shape",
"[",
":",
"2",
"]",
"mapx",
",",
"mapy",
"=",
"self",
".",
"getDistortRectifyMa... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.getCameraParams | value positions based on
http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#cv.InitUndistortRectifyMap | imgProcessor/camera/LensDistortion.py | 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):
'''
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... | [
"value",
"positions",
"based",
"on",
"http",
":",
"//",
"docs",
".",
"opencv",
".",
"org",
"/",
"modules",
"/",
"imgproc",
"/",
"doc",
"/",
"geometric_transformations",
".",
"html#cv",
".",
"InitUndistortRectifyMap"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L360-L371 | [
"def",
"getCameraParams",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"coeffs",
"[",
"'cameraMatrix'",
"]",
"fx",
"=",
"c",
"[",
"0",
"]",
"[",
"0",
"]",
"fy",
"=",
"c",
"[",
"1",
"]",
"[",
"1",
"]",
"cx",
"=",
"c",
"[",
"0",
"]",
"[",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | LensDistortion.standardUncertainties | 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 | imgProcessor/camera/LensDistortion.py | 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):
'''
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... | [
"sharpness",
"-",
">",
"image",
"sharpness",
"//",
"std",
"of",
"Gaussian",
"PSF",
"[",
"px",
"]",
"returns",
"a",
"list",
"of",
"standard",
"uncertainties",
"for",
"the",
"x",
"and",
"y",
"component",
":",
"(",
"1x",
"2x",
")",
"(",
"1y",
"2y",
")",... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/LensDistortion.py#L404-L418 | [
"def",
"standardUncertainties",
"(",
"self",
",",
"sharpness",
"=",
"0.5",
")",
":",
"height",
",",
"width",
"=",
"self",
".",
"coeffs",
"[",
"'shape'",
"]",
"fx",
",",
"fy",
"=",
"self",
".",
"getDeflection",
"(",
"width",
",",
"height",
")",
"# is RM... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | edgesFromBoolImg | takes a binary image (usually a mask)
and returns the edges of the object inside | imgProcessor/filters/edgesFromBoolImg.py | 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):
'''
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 | [
"takes",
"a",
"binary",
"image",
"(",
"usually",
"a",
"mask",
")",
"and",
"returns",
"the",
"edges",
"of",
"the",
"object",
"inside"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/edgesFromBoolImg.py#L5-L13 | [
"def",
"edgesFromBoolImg",
"(",
"arr",
",",
"dtype",
"=",
"None",
")",
":",
"out",
"=",
"np",
".",
"zeros_like",
"(",
"arr",
",",
"dtype",
"=",
"dtype",
")",
"_calc",
"(",
"arr",
",",
"out",
")",
"_calc",
"(",
"arr",
".",
"T",
",",
"out",
".",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | draw_matches | 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.
... | imgProcessor/features/PatternRecognition.py | 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):
"""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... | [
"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",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L203-L252 | [
"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... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | PatternRecognition._scaleTo8bit | The pattern comparator need images to be 8 bit
-> find the range of the signal and scale the image | imgProcessor/features/PatternRecognition.py | 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):
'''
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... | [
"The",
"pattern",
"comparator",
"need",
"images",
"to",
"be",
"8",
"bit",
"-",
">",
"find",
"the",
"range",
"of",
"the",
"signal",
"and",
"scale",
"the",
"image"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L89-L96 | [
"def",
"_scaleTo8bit",
"(",
"self",
",",
"img",
")",
":",
"r",
"=",
"scaleSignalCutParams",
"(",
"img",
",",
"0.02",
")",
"# , nSigma=3)\r",
"self",
".",
"signal_ranges",
".",
"append",
"(",
"r",
")",
"return",
"toUIntArray",
"(",
"img",
",",
"dtype",
"=... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | PatternRecognition.findHomography | Find homography of the image through pattern
comparison with the base image | imgProcessor/features/PatternRecognition.py | 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):
'''
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... | [
"Find",
"homography",
"of",
"the",
"image",
"through",
"pattern",
"comparison",
"with",
"the",
"base",
"image"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/features/PatternRecognition.py#L108-L196 | [
"def",
"findHomography",
"(",
"self",
",",
"img",
",",
"drawMatches",
"=",
"False",
")",
":",
"print",
"(",
"\"\\t Finding points...\"",
")",
"# Find points in the next frame\r",
"img",
"=",
"self",
".",
"_prepareImage",
"(",
"img",
")",
"features",
",",
"descs"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | patCircles | make circle array | imgProcessor/generate/patterns.py | 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):
'''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... | [
"make",
"circle",
"array"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L5-L18 | [
"def",
"patCircles",
"(",
"s0",
")",
":",
"arr",
"=",
"np",
".",
"zeros",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"col",
"=",
"255",
"for",
"rad",
"in",
"np",
".",
"linspace",
"(",
"s0",
",",
"s0",
"/",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | patCrossLines | make line pattern | imgProcessor/generate/patterns.py | 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):
'''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... | [
"make",
"line",
"pattern"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L21-L33 | [
"def",
"patCrossLines",
"(",
"s0",
")",
":",
"arr",
"=",
"np",
".",
"zeros",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"col",
"=",
"255",
"t",
"=",
"int",
"(",
"s0",
"/",
"100.",
")",
"for",
"pos",
"in",
"n... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | patStarLines | make line pattern | imgProcessor/generate/patterns.py | 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):
'''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... | [
"make",
"line",
"pattern"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L68-L80 | [
"def",
"patStarLines",
"(",
"s0",
")",
":",
"arr",
"=",
"np",
".",
"zeros",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"col",
"=",
"255",
"t",
"=",
"int",
"(",
"s0",
"/",
"100.",
")",
"for",
"pos",
"in",
"np... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | patSiemensStar | make line pattern | imgProcessor/generate/patterns.py | 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):
'''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)
... | [
"make",
"line",
"pattern"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L83-L107 | [
"def",
"patSiemensStar",
"(",
"s0",
",",
"n",
"=",
"72",
",",
"vhigh",
"=",
"255",
",",
"vlow",
"=",
"0",
",",
"antiasing",
"=",
"False",
")",
":",
"arr",
"=",
"np",
".",
"full",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"vlow",
",",
"dtype",
"=",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | patText | make text pattern | imgProcessor/generate/patterns.py | 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):
'''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... | [
"make",
"text",
"pattern"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L140-L155 | [
"def",
"patText",
"(",
"s0",
")",
":",
"arr",
"=",
"np",
".",
"zeros",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"s",
"=",
"int",
"(",
"round",
"(",
"s0",
"/",
"100.",
")",
")",
"p1",
"=",
"0",
"pp1",
"="... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | removeSinglePixels | img - boolean array
remove all pixels that have no neighbour | imgProcessor/filters/removeSinglePixels.py | 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):
'''
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... | [
"img",
"-",
"boolean",
"array",
"remove",
"all",
"pixels",
"that",
"have",
"no",
"neighbour"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/removeSinglePixels.py#L5-L33 | [
"def",
"removeSinglePixels",
"(",
"img",
")",
":",
"gx",
"=",
"img",
".",
"shape",
"[",
"0",
"]",
"gy",
"=",
"img",
".",
"shape",
"[",
"1",
"]",
"for",
"i",
"in",
"range",
"(",
"gx",
")",
":",
"for",
"j",
"in",
"range",
"(",
"gy",
")",
":",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | interpolateCircular2dStructuredIDW | 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) | imgProcessor/interpolate/interpolateCircular2dStructuredIDW.py | 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):
'''
same as interpolate2dStructuredIDW
but calculation distance to neighbour using polar coordinates
fr, fphi --> weight factors for radian and radius differences
c... | [
"same",
"as",
"interpolate2dStructuredIDW",
"but",
"calculation",
"distance",
"to",
"neighbour",
"using",
"polar",
"coordinates",
"fr",
"fphi",
"--",
">",
"weight",
"factors",
"for",
"radian",
"and",
"radius",
"differences",
"cx",
"cy",
"-",
">",
"polar",
"cente... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolateCircular2dStructuredIDW.py#L8-L69 | [
"def",
"interpolateCircular2dStructuredIDW",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
",",
"fr",
"=",
"1",
",",
"fphi",
"=",
"1",
",",
"cx",
"=",
"0",
",",
"cy",
"=",
"0",
")",
":",
"gx",
"=",
"grid",
".",
"sh... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | interpolate2dStructuredCrossAvg | #######
usefull if large empty areas need to be filled | imgProcessor/interpolate/interpolate2dStructuredCrossAvg.py | 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):
'''
#######
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... | [
"#######",
"usefull",
"if",
"large",
"empty",
"areas",
"need",
"to",
"be",
"filled"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredCrossAvg.py#L7-L19 | [
"def",
"interpolate2dStructuredCrossAvg",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
")",
":",
"vals",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"4",
",",
"dtype",
"=",
"grid",
".",
"dtype",
")",
"dist",
"=",
"np"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | growPositions | 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 | imgProcessor/utils/growPositions.py | 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):
'''
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... | [
"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... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/growPositions.py#L5-L31 | [
"def",
"growPositions",
"(",
"ksize",
")",
":",
"i",
"=",
"ksize",
"*",
"2",
"+",
"1",
"kk",
"=",
"np",
".",
"ones",
"(",
"(",
"i",
",",
"i",
")",
",",
"dtype",
"=",
"bool",
")",
"x",
",",
"y",
"=",
"np",
".",
"where",
"(",
"kk",
")",
"po... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | qImageToArray | 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. | imgProcessor/reader/qImageToArray.py | 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'):
"""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",
".",... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/reader/qImageToArray.py#L8-L43 | [
"def",
"qImageToArray",
"(",
"qimage",
",",
"dtype",
"=",
"'array'",
")",
":",
"result_shape",
"=",
"(",
"qimage",
".",
"height",
"(",
")",
",",
"qimage",
".",
"width",
"(",
")",
")",
"temp_shape",
"=",
"(",
"qimage",
".",
"height",
"(",
")",
",",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | varYSizeGaussianFilter | 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 | imgProcessor/filters/varYSizeGaussianFilter.py | 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'):
'''
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) -> ... | [
"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",
"(",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/varYSizeGaussianFilter.py#L9-L50 | [
"def",
"varYSizeGaussianFilter",
"(",
"arr",
",",
"stdyrange",
",",
"stdx",
"=",
"0",
",",
"modex",
"=",
"'wrap'",
",",
"modey",
"=",
"'reflect'",
")",
":",
"assert",
"arr",
".",
"ndim",
"==",
"2",
",",
"'only works on 2d arrays at the moment'",
"s0",
"=",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | numbaGaussian2d | 2d Gaussian to be used in numba code | imgProcessor/equations/numbaGaussian2d.py | 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):
'''
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... | [
"2d",
"Gaussian",
"to",
"be",
"used",
"in",
"numba",
"code"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/numbaGaussian2d.py#L10-L22 | [
"def",
"numbaGaussian2d",
"(",
"psf",
",",
"sy",
",",
"sx",
")",
":",
"ps0",
",",
"ps1",
"=",
"psf",
".",
"shape",
"c0",
",",
"c1",
"=",
"ps0",
"//",
"2",
",",
"ps1",
"//",
"2",
"ssx",
"=",
"2",
"*",
"sx",
"**",
"2",
"ssy",
"=",
"2",
"*",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | estimateBackgroundLevel | estimate background level through finding the most homogeneous area
and take its average
min_size - relative size of the examined area | imgProcessor/measure/SNR/estimateBackgroundLevel.py | 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):
'''
estimate background level through finding the most homogeneous area
and take its average
min_size - relative size of the examined area
'''
s0,s1 = i... | [
"estimate",
"background",
"level",
"through",
"finding",
"the",
"most",
"homogeneous",
"area",
"and",
"take",
"its",
"average",
"min_size",
"-",
"relative",
"size",
"of",
"the",
"examined",
"area"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/estimateBackgroundLevel.py#L11-L31 | [
"def",
"estimateBackgroundLevel",
"(",
"img",
",",
"image_is_artefact_free",
"=",
"False",
",",
"min_rel_size",
"=",
"0.05",
",",
"max_abs_size",
"=",
"11",
")",
":",
"s0",
",",
"s1",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"s",
"=",
"min",
"(",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | 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 | imgProcessor/physics/emissivity_vs_angle.py | 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():
'''
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... | [
"returns",
"angular",
"dependent",
"EL",
"emissivity",
"of",
"a",
"PV",
"module",
"calculated",
"of",
"nanmedian",
"(",
"persp",
"-",
"corrected",
"EL",
"module",
"/",
"reference",
"module",
")",
"published",
"in",
"K",
".",
"Bedrich",
":",
"Quantitative",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/physics/emissivity_vs_angle.py#L8-L42 | [
"def",
"EL_Si_module",
"(",
")",
":",
"arr",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"2.5",
",",
"1.00281",
"]",
",",
"[",
"7.5",
",",
"1.00238",
"]",
",",
"[",
"12.5",
",",
"1.00174",
"]",
",",
"[",
"17.5",
",",
"1.00204",
"]",
",",
"[",
"22... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | 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 | imgProcessor/physics/emissivity_vs_angle.py | 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():
'''
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... | [
"reflected",
"temperature",
"for",
"250DEG",
"Glass",
"published",
"in",
"IEC",
"62446",
"-",
"3",
"TS",
":",
"Photovoltaic",
"(",
"PV",
")",
"systems",
"-",
"Requirements",
"for",
"testing",
"documentation",
"and",
"maintenance",
"-",
"Part",
"3",
":",
"Out... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/physics/emissivity_vs_angle.py#L45-L72 | [
"def",
"TG_glass",
"(",
")",
":",
"vals",
"=",
"np",
".",
"array",
"(",
"[",
"(",
"80",
",",
"0.88",
")",
",",
"(",
"75",
",",
"0.88",
")",
",",
"(",
"70",
",",
"0.88",
")",
",",
"(",
"65",
",",
"0.88",
")",
",",
"(",
"60",
",",
"0.88",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | sensitivity | 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
--- | imgProcessor/camera/flatField/sensitivity.py | 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):
'''
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... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/sensitivity.py#L7-L30 | [
"def",
"sensitivity",
"(",
"imgs",
",",
"bg",
"=",
"None",
")",
":",
"bg",
"=",
"getBackground",
"(",
"bg",
")",
"for",
"n",
",",
"i",
"in",
"enumerate",
"(",
"imgs",
")",
":",
"i",
"=",
"imread",
"(",
"i",
",",
"dtype",
"=",
"float",
")",
"i",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | navierStokes2d | 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... | imgProcessor/simulate/navierStokes.py | 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):
'''
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... | [
"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",
"--",
">"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/simulate/navierStokes.py#L8-L49 | [
"def",
"navierStokes2d",
"(",
"u",
",",
"v",
",",
"p",
",",
"dt",
",",
"nt",
",",
"rho",
",",
"nu",
",",
"boundaryConditionUV",
",",
"boundardConditionP",
",",
"nit",
"=",
"100",
")",
":",
"#next u, v, p maps:\r",
"un",
"=",
"np",
".",
"empty_like",
"(... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | shiftImage | remap an image using velocity field | imgProcessor/simulate/navierStokes.py | 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):
'''
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),
... | [
"remap",
"an",
"image",
"using",
"velocity",
"field"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/simulate/navierStokes.py#L52-L62 | [
"def",
"shiftImage",
"(",
"u",
",",
"v",
",",
"t",
",",
"img",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_LANCZOS4",
")",
":",
"ny",
",",
"nx",
"=",
"u",
".",
"shape",
"sy",
",",
"sx",
"=",
"np",
".",
"mgrid",
"[",
":",
"float",
"(",
"ny",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | addNoise | adds Gaussian (thermal) and shot noise to [img]
[img] is assumed to be noise free
[rShot] - shot noise ratio relative to all noise | imgProcessor/filters/addNoise.py | 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):
'''
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... | [
"adds",
"Gaussian",
"(",
"thermal",
")",
"and",
"shot",
"noise",
"to",
"[",
"img",
"]",
"[",
"img",
"]",
"is",
"assumed",
"to",
"be",
"noise",
"free",
"[",
"rShot",
"]",
"-",
"shot",
"noise",
"ratio",
"relative",
"to",
"all",
"noise"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/addNoise.py#L4-L25 | [
"def",
"addNoise",
"(",
"img",
",",
"snr",
"=",
"25",
",",
"rShot",
"=",
"0.5",
")",
":",
"s0",
",",
"s1",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"m",
"=",
"img",
".",
"mean",
"(",
")",
"if",
"np",
".",
"isnan",
"(",
"m",
")",
":",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | coarseMaximum | return an array of [shape]
where every cell equals the localised maximum of the given array [arr]
at the same (scalled) position | imgProcessor/filters/coarseMaximum.py | 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):
'''
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, ... | [
"return",
"an",
"array",
"of",
"[",
"shape",
"]",
"where",
"every",
"cell",
"equals",
"the",
"localised",
"maximum",
"of",
"the",
"given",
"array",
"[",
"arr",
"]",
"at",
"the",
"same",
"(",
"scalled",
")",
"position"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/coarseMaximum.py#L8-L25 | [
"def",
"coarseMaximum",
"(",
"arr",
",",
"shape",
")",
":",
"ss0",
",",
"ss1",
"=",
"shape",
"s0",
",",
"s1",
"=",
"arr",
".",
"shape",
"pos0",
"=",
"linspace2",
"(",
"0",
",",
"s0",
",",
"ss0",
",",
"dtype",
"=",
"int",
")",
"pos1",
"=",
"lins... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | angleOfView | 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... | imgProcessor/equations/angleOfView.py | 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):
'''
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... | [
"Another",
"vignetting",
"equation",
"from",
":",
"M",
".",
"Koentges",
"M",
".",
"Siebert",
"and",
"D",
".",
"Hinken",
"Quantitative",
"analysis",
"of",
"PV",
"-",
"modules",
"by",
"electroluminescence",
"images",
"for",
"quality",
"control",
"2009",
"f",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/angleOfView.py#L12-L40 | [
"def",
"angleOfView",
"(",
"XY",
",",
"shape",
"=",
"None",
",",
"a",
"=",
"None",
",",
"f",
"=",
"None",
",",
"D",
"=",
"None",
",",
"center",
"=",
"None",
")",
":",
"if",
"a",
"is",
"None",
":",
"assert",
"f",
"is",
"not",
"None",
"and",
"D... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | angleOfView2 | 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 | imgProcessor/equations/angleOfView.py | 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):
'''
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
... | [
"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... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/angleOfView.py#L43-L56 | [
"def",
"angleOfView2",
"(",
"x",
",",
"y",
",",
"b",
",",
"x0",
"=",
"None",
",",
"y0",
"=",
"None",
")",
":",
"if",
"x0",
"is",
"None",
":",
"x0",
"=",
"x",
"[",
"-",
"1",
",",
"-",
"1",
"]",
"if",
"y0",
"is",
"None",
":",
"y0",
"=",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | gridLinesFromVertices | ###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,... | imgProcessor/utils/gridLinesFromVertices.py | 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):
"""
###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) ... | [
"###TODO",
"REDO",
"TXT",
"OPTIONAL",
":",
"subgrid",
"=",
"(",
"[",
"x",
"]",
"[",
"y",
"]",
")",
"--",
">",
"relative",
"positions",
"e",
".",
"g",
".",
"subgrid",
"=",
"(",
"(",
"0",
".",
"3",
"0",
".",
"7",
")",
"()",
")",
"--",
">",
"t... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/gridLinesFromVertices.py#L39-L107 | [
"def",
"gridLinesFromVertices",
"(",
"edges",
",",
"nCells",
",",
"subgrid",
"=",
"None",
",",
"dtype",
"=",
"float",
")",
":",
"nx",
",",
"ny",
"=",
"nCells",
"y",
",",
"x",
"=",
"np",
".",
"mgrid",
"[",
"0.",
":",
"ny",
"+",
"1",
",",
"0.",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SharpnessBase.MTF50 | return object resolution as [line pairs/mm]
where MTF=50%
see http://www.imatest.com/docs/sharpness/ | imgProcessor/measure/sharpness/_base.py | 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):
'''
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... | [
"return",
"object",
"resolution",
"as",
"[",
"line",
"pairs",
"/",
"mm",
"]",
"where",
"MTF",
"=",
"50%",
"see",
"http",
":",
"//",
"www",
".",
"imatest",
".",
"com",
"/",
"docs",
"/",
"sharpness",
"/"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L21-L30 | [
"def",
"MTF50",
"(",
"self",
",",
"MTFx",
",",
"MTFy",
")",
":",
"if",
"self",
".",
"mtf_x",
"is",
"None",
":",
"self",
".",
"MTF",
"(",
")",
"f",
"=",
"UnivariateSpline",
"(",
"self",
".",
"mtf_x",
",",
"self",
".",
"mtf_y",
"-",
"0.5",
")",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SharpnessBase.MTF | px_per_mm = cam_resolution / image_size | imgProcessor/measure/sharpness/_base.py | def MTF(self, px_per_mm):
'''
px_per_mm = cam_resolution / image_size
'''
res = 100 #numeric resolution
r = 4 #range +-r*std
#size of 1 px:
px_size = 1 / px_per_mm
#standard deviation of the point-spread-function (PSF) as normal... | def MTF(self, px_per_mm):
'''
px_per_mm = cam_resolution / image_size
'''
res = 100 #numeric resolution
r = 4 #range +-r*std
#size of 1 px:
px_size = 1 / px_per_mm
#standard deviation of the point-spread-function (PSF) as normal... | [
"px_per_mm",
"=",
"cam_resolution",
"/",
"image_size"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L33-L62 | [
"def",
"MTF",
"(",
"self",
",",
"px_per_mm",
")",
":",
"res",
"=",
"100",
"#numeric resolution\r",
"r",
"=",
"4",
"#range +-r*std\r",
"#size of 1 px:\r",
"px_size",
"=",
"1",
"/",
"px_per_mm",
"#standard deviation of the point-spread-function (PSF) as normal distributed:\... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SharpnessBase.uncertaintyMap | return the intensity based uncertainty due to the unsharpness of the image
as standard deviation
method = ['convolve' , 'unsupervised_wiener']
latter one also returns the reconstructed image (deconvolution) | imgProcessor/measure/sharpness/_base.py | def uncertaintyMap(self, psf, method='convolve', fitParams=None):
'''
return the intensity based uncertainty due to the unsharpness of the image
as standard deviation
method = ['convolve' , 'unsupervised_wiener']
latter one also returns the reconstructe... | def uncertaintyMap(self, psf, method='convolve', fitParams=None):
'''
return the intensity based uncertainty due to the unsharpness of the image
as standard deviation
method = ['convolve' , 'unsupervised_wiener']
latter one also returns the reconstructe... | [
"return",
"the",
"intensity",
"based",
"uncertainty",
"due",
"to",
"the",
"unsharpness",
"of",
"the",
"image",
"as",
"standard",
"deviation",
"method",
"=",
"[",
"convolve",
"unsupervised_wiener",
"]",
"latter",
"one",
"also",
"returns",
"the",
"reconstructed",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L66-L100 | [
"def",
"uncertaintyMap",
"(",
"self",
",",
"psf",
",",
"method",
"=",
"'convolve'",
",",
"fitParams",
"=",
"None",
")",
":",
"#ignore background:\r",
"#img[img<0]=0\r",
"###noise should not influence sharpness uncertainty:\r",
"##img = median_filter(img, 3)\r",
"# decrease no... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SharpnessBase.stdDev | get the standard deviation
from the PSF is evaluated as 2d Gaussian | imgProcessor/measure/sharpness/_base.py | def stdDev(self):
'''
get the standard deviation
from the PSF is evaluated as 2d Gaussian
'''
if self._corrPsf is None:
self.psf()
p = self._corrPsf.copy()
mn = p.min()
p[p<0.05*p.max()] = mn
p-=mn
p/=p.sum()
... | def stdDev(self):
'''
get the standard deviation
from the PSF is evaluated as 2d Gaussian
'''
if self._corrPsf is None:
self.psf()
p = self._corrPsf.copy()
mn = p.min()
p[p<0.05*p.max()] = mn
p-=mn
p/=p.sum()
... | [
"get",
"the",
"standard",
"deviation",
"from",
"the",
"PSF",
"is",
"evaluated",
"as",
"2d",
"Gaussian"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L160-L185 | [
"def",
"stdDev",
"(",
"self",
")",
":",
"if",
"self",
".",
"_corrPsf",
"is",
"None",
":",
"self",
".",
"psf",
"(",
")",
"p",
"=",
"self",
".",
"_corrPsf",
".",
"copy",
"(",
")",
"mn",
"=",
"p",
".",
"min",
"(",
")",
"p",
"[",
"p",
"<",
"0.0... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | 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] | imgProcessor/interpolate/interpolate2dStructuredIDW.py | def interpolate2dStructuredIDW(grid, mask, kernel=15, power=2, fx=1, fy=1):
'''
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]
'''
weights = ... | def interpolate2dStructuredIDW(grid, mask, kernel=15, power=2, fx=1, fy=1):
'''
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]
'''
weights = ... | [
"replace",
"all",
"values",
"in",
"[",
"grid",
"]",
"indicated",
"by",
"[",
"mask",
"]",
"with",
"the",
"inverse",
"distance",
"weighted",
"interpolation",
"of",
"all",
"values",
"within",
"px",
"+",
"-",
"kernel",
"[",
"power",
"]",
"-",
">",
"distance"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredIDW.py#L8-L23 | [
"def",
"interpolate2dStructuredIDW",
"(",
"grid",
",",
"mask",
",",
"kernel",
"=",
"15",
",",
"power",
"=",
"2",
",",
"fx",
"=",
"1",
",",
"fy",
"=",
"1",
")",
":",
"weights",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"(",
"(",
"2",
"*",
"ker... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | temporalSignalStability | (Electroluminescence) signal is not stable over time
especially next to cracks.
This function takes a set of images
and returns parameters, needed to transform uncertainty
to other exposure times using [adjustUncertToExposureTime]
return [signal uncertainty] obtained from l... | imgProcessor/uncertainty/temporalSignalStability.py | def temporalSignalStability(imgs, times, down_scale_factor=1):
'''
(Electroluminescence) signal is not stable over time
especially next to cracks.
This function takes a set of images
and returns parameters, needed to transform uncertainty
to other exposure times using [adjustUncer... | def temporalSignalStability(imgs, times, down_scale_factor=1):
'''
(Electroluminescence) signal is not stable over time
especially next to cracks.
This function takes a set of images
and returns parameters, needed to transform uncertainty
to other exposure times using [adjustUncer... | [
"(",
"Electroluminescence",
")",
"signal",
"is",
"not",
"stable",
"over",
"time",
"especially",
"next",
"to",
"cracks",
".",
"This",
"function",
"takes",
"a",
"set",
"of",
"images",
"and",
"returns",
"parameters",
"needed",
"to",
"transform",
"uncertainty",
"t... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/temporalSignalStability.py#L12-L80 | [
"def",
"temporalSignalStability",
"(",
"imgs",
",",
"times",
",",
"down_scale_factor",
"=",
"1",
")",
":",
"imgs",
"=",
"np",
".",
"asarray",
"(",
"imgs",
")",
"s0",
",",
"s1",
",",
"s2",
"=",
"imgs",
".",
"shape",
"#down scale imgs to speed up process:\r",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | vignettingFromSpotAverage | [images] --> list of images containing
small bright spots generated by the same
device images at different positions within image plane
depending on the calibrated waveband the device can be
a LCD display or PV 1-cell mini module
This method is refe... | imgProcessor/camera/flatField/vignettingFromSpotAverage.py | def vignettingFromSpotAverage(
images, bgImages=None, averageSpot=True, thresh=None):
'''
[images] --> list of images containing
small bright spots generated by the same
device images at different positions within image plane
depending on the calibrat... | def vignettingFromSpotAverage(
images, bgImages=None, averageSpot=True, thresh=None):
'''
[images] --> list of images containing
small bright spots generated by the same
device images at different positions within image plane
depending on the calibrat... | [
"[",
"images",
"]",
"--",
">",
"list",
"of",
"images",
"containing",
"small",
"bright",
"spots",
"generated",
"by",
"the",
"same",
"device",
"images",
"at",
"different",
"positions",
"within",
"image",
"plane",
"depending",
"on",
"the",
"calibrated",
"waveband... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromSpotAverage.py#L15-L85 | [
"def",
"vignettingFromSpotAverage",
"(",
"images",
",",
"bgImages",
"=",
"None",
",",
"averageSpot",
"=",
"True",
",",
"thresh",
"=",
"None",
")",
":",
"fitimg",
",",
"mask",
"=",
"None",
",",
"None",
"mx",
"=",
"0",
"for",
"c",
",",
"img",
"in",
"en... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | simulateSytematicError | Simulates a lens calibration using synthetic images
* images are rendered under the given HEIGHT resolution
* noise and smoothing is applied
* perspective and position errors are applied
* images are deformed using the given CAMERA_PARAM
* the detected camera parameters are used to calculate ... | imgProcessor/camera/lens/estimateSystematicErrorLensCorrection.py | def simulateSytematicError(N_SAMPLES=5, N_IMAGES=10,
SHOW_DETECTED_PATTERN=True, # GRAYSCALE=False,
HEIGHT=500, PLOT_RESULTS=True, PLOT_ERROR_ARRAY=True,
CAMERA_PARAM=None, PERSPECTIVE=True, ROTATION=True,
R... | def simulateSytematicError(N_SAMPLES=5, N_IMAGES=10,
SHOW_DETECTED_PATTERN=True, # GRAYSCALE=False,
HEIGHT=500, PLOT_RESULTS=True, PLOT_ERROR_ARRAY=True,
CAMERA_PARAM=None, PERSPECTIVE=True, ROTATION=True,
R... | [
"Simulates",
"a",
"lens",
"calibration",
"using",
"synthetic",
"images",
"*",
"images",
"are",
"rendered",
"under",
"the",
"given",
"HEIGHT",
"resolution",
"*",
"noise",
"and",
"smoothing",
"is",
"applied",
"*",
"perspective",
"and",
"position",
"errors",
"are",... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/lens/estimateSystematicErrorLensCorrection.py#L24-L384 | [
"def",
"simulateSytematicError",
"(",
"N_SAMPLES",
"=",
"5",
",",
"N_IMAGES",
"=",
"10",
",",
"SHOW_DETECTED_PATTERN",
"=",
"True",
",",
"# GRAYSCALE=False,\r",
"HEIGHT",
"=",
"500",
",",
"PLOT_RESULTS",
"=",
"True",
",",
"PLOT_ERROR_ARRAY",
"=",
"True",
",",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | plotSet | creates plots showing both found GAUSSIAN peaks, the histogram, a smoothed histogram
from all images within [imgDir]
posExTime - position range of the exposure time in the image name e.g.: img_30s.jpg -> (4,5)
outDir - dirname to save the output images
show_legend - True/False
show_plots - di... | imgProcessor/scripts/_FitHistogramPeaks.py | def plotSet(imgDir, posExTime, outDir, show_legend,
show_plots, save_to_file, ftype):
'''
creates plots showing both found GAUSSIAN peaks, the histogram, a smoothed histogram
from all images within [imgDir]
posExTime - position range of the exposure time in the image name e.g.: img_30... | def plotSet(imgDir, posExTime, outDir, show_legend,
show_plots, save_to_file, ftype):
'''
creates plots showing both found GAUSSIAN peaks, the histogram, a smoothed histogram
from all images within [imgDir]
posExTime - position range of the exposure time in the image name e.g.: img_30... | [
"creates",
"plots",
"showing",
"both",
"found",
"GAUSSIAN",
"peaks",
"the",
"histogram",
"a",
"smoothed",
"histogram",
"from",
"all",
"images",
"within",
"[",
"imgDir",
"]",
"posExTime",
"-",
"position",
"range",
"of",
"the",
"exposure",
"time",
"in",
"the",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/scripts/_FitHistogramPeaks.py#L47-L126 | [
"def",
"plotSet",
"(",
"imgDir",
",",
"posExTime",
",",
"outDir",
",",
"show_legend",
",",
"show_plots",
",",
"save_to_file",
",",
"ftype",
")",
":",
"xvals",
"=",
"[",
"]",
"hist",
"=",
"[",
"]",
"peaks",
"=",
"[",
"]",
"exTimes",
"=",
"[",
"]",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | flatFieldFromCloseDistance | Average multiple images of a homogeneous device
imaged directly in front the camera lens.
if [bg_imgs] are not given, background level is extracted
from 1% of the cumulative intensity distribution
of the averaged [imgs]
This measurement method is referred as 'Method A' in
---
... | imgProcessor/camera/flatField/flatFieldFromCloseDistance.py | def flatFieldFromCloseDistance(imgs, bg_imgs=None):
'''
Average multiple images of a homogeneous device
imaged directly in front the camera lens.
if [bg_imgs] are not given, background level is extracted
from 1% of the cumulative intensity distribution
of the averaged [imgs]
... | def flatFieldFromCloseDistance(imgs, bg_imgs=None):
'''
Average multiple images of a homogeneous device
imaged directly in front the camera lens.
if [bg_imgs] are not given, background level is extracted
from 1% of the cumulative intensity distribution
of the averaged [imgs]
... | [
"Average",
"multiple",
"images",
"of",
"a",
"homogeneous",
"device",
"imaged",
"directly",
"in",
"front",
"the",
"camera",
"lens",
".",
"if",
"[",
"bg_imgs",
"]",
"are",
"not",
"given",
"background",
"level",
"is",
"extracted",
"from",
"1%",
"of",
"the",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/flatFieldFromCloseDistance.py#L16-L38 | [
"def",
"flatFieldFromCloseDistance",
"(",
"imgs",
",",
"bg_imgs",
"=",
"None",
")",
":",
"img",
"=",
"imgAverage",
"(",
"imgs",
")",
"bg",
"=",
"getBackground2",
"(",
"bg_imgs",
",",
"img",
")",
"img",
"-=",
"bg",
"img",
"=",
"toGray",
"(",
"img",
")",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | flatFieldFromCloseDistance2 | Same as [flatFieldFromCloseDistance]. Differences are:
... single-time-effect removal included
... returns the standard deviation of the image average [calcStd=True]
Optional:
-----------
calcStd -> set to True to also return the standard deviation
nlf -> noise level function (callable)
... | imgProcessor/camera/flatField/flatFieldFromCloseDistance.py | def flatFieldFromCloseDistance2(images, bgImages=None, calcStd=False,
nlf=None, nstd=6):
'''
Same as [flatFieldFromCloseDistance]. Differences are:
... single-time-effect removal included
... returns the standard deviation of the image average [calcStd=True]
O... | def flatFieldFromCloseDistance2(images, bgImages=None, calcStd=False,
nlf=None, nstd=6):
'''
Same as [flatFieldFromCloseDistance]. Differences are:
... single-time-effect removal included
... returns the standard deviation of the image average [calcStd=True]
O... | [
"Same",
"as",
"[",
"flatFieldFromCloseDistance",
"]",
".",
"Differences",
"are",
":",
"...",
"single",
"-",
"time",
"-",
"effect",
"removal",
"included",
"...",
"returns",
"the",
"standard",
"deviation",
"of",
"the",
"image",
"average",
"[",
"calcStd",
"=",
... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/flatFieldFromCloseDistance.py#L41-L96 | [
"def",
"flatFieldFromCloseDistance2",
"(",
"images",
",",
"bgImages",
"=",
"None",
",",
"calcStd",
"=",
"False",
",",
"nlf",
"=",
"None",
",",
"nstd",
"=",
"6",
")",
":",
"if",
"len",
"(",
"images",
")",
">",
"1",
":",
"# start with brightest images\r",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | SNR_hinken | signal-to-noise ratio (SNR) as mean(images) / std(images)
as defined in Hinken et.al. 2011 (DOI: 10.1063/1.3541766)
works on unloaded images
no memory overload if too many images are given | imgProcessor/measure/SNR/SNR_hinken.py | def SNR_hinken(imgs, bg=0, roi=None):
'''
signal-to-noise ratio (SNR) as mean(images) / std(images)
as defined in Hinken et.al. 2011 (DOI: 10.1063/1.3541766)
works on unloaded images
no memory overload if too many images are given
'''
mean = None
M = len(imgs)
if bg is... | def SNR_hinken(imgs, bg=0, roi=None):
'''
signal-to-noise ratio (SNR) as mean(images) / std(images)
as defined in Hinken et.al. 2011 (DOI: 10.1063/1.3541766)
works on unloaded images
no memory overload if too many images are given
'''
mean = None
M = len(imgs)
if bg is... | [
"signal",
"-",
"to",
"-",
"noise",
"ratio",
"(",
"SNR",
")",
"as",
"mean",
"(",
"images",
")",
"/",
"std",
"(",
"images",
")",
"as",
"defined",
"in",
"Hinken",
"et",
".",
"al",
".",
"2011",
"(",
"DOI",
":",
"10",
".",
"1063",
"/",
"1",
".",
"... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNR_hinken.py#L8-L44 | [
"def",
"SNR_hinken",
"(",
"imgs",
",",
"bg",
"=",
"0",
",",
"roi",
"=",
"None",
")",
":",
"mean",
"=",
"None",
"M",
"=",
"len",
"(",
"imgs",
")",
"if",
"bg",
"is",
"not",
"0",
":",
"bg",
"=",
"imread",
"(",
"bg",
")",
"[",
"roi",
"]",
"if",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | boolMasksToImage | Transform at maximum 8 bool layers --> 2d arrays, dtype=(bool,int)
to one 8bit image | imgProcessor/transform/boolImg.py | def boolMasksToImage(masks):
'''
Transform at maximum 8 bool layers --> 2d arrays, dtype=(bool,int)
to one 8bit image
'''
assert len(masks) <= 8, 'can only transform up to 8 masks into image'
masks = np.asarray(masks, dtype=np.uint8)
assert masks.ndim == 3, 'layers need to be stack of... | def boolMasksToImage(masks):
'''
Transform at maximum 8 bool layers --> 2d arrays, dtype=(bool,int)
to one 8bit image
'''
assert len(masks) <= 8, 'can only transform up to 8 masks into image'
masks = np.asarray(masks, dtype=np.uint8)
assert masks.ndim == 3, 'layers need to be stack of... | [
"Transform",
"at",
"maximum",
"8",
"bool",
"layers",
"--",
">",
"2d",
"arrays",
"dtype",
"=",
"(",
"bool",
"int",
")",
"to",
"one",
"8bit",
"image"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/boolImg.py#L4-L12 | [
"def",
"boolMasksToImage",
"(",
"masks",
")",
":",
"assert",
"len",
"(",
"masks",
")",
"<=",
"8",
",",
"'can only transform up to 8 masks into image'",
"masks",
"=",
"np",
".",
"asarray",
"(",
"masks",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"assert",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | imageToBoolMasks | inverse of [boolMasksToImage] | imgProcessor/transform/boolImg.py | def imageToBoolMasks(arr):
'''inverse of [boolMasksToImage]'''
assert arr.dtype == np.uint8, 'image needs to be dtype=uint8'
masks = np.unpackbits(arr).reshape(*arr.shape, 8)
return np.swapaxes(masks, 2, 0) | def imageToBoolMasks(arr):
'''inverse of [boolMasksToImage]'''
assert arr.dtype == np.uint8, 'image needs to be dtype=uint8'
masks = np.unpackbits(arr).reshape(*arr.shape, 8)
return np.swapaxes(masks, 2, 0) | [
"inverse",
"of",
"[",
"boolMasksToImage",
"]"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/boolImg.py#L15-L19 | [
"def",
"imageToBoolMasks",
"(",
"arr",
")",
":",
"assert",
"arr",
".",
"dtype",
"==",
"np",
".",
"uint8",
",",
"'image needs to be dtype=uint8'",
"masks",
"=",
"np",
".",
"unpackbits",
"(",
"arr",
")",
".",
"reshape",
"(",
"*",
"arr",
".",
"shape",
",",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | calcAspectRatioFromCorners | simple and better alg. than below
in_plane -> whether object has no tilt, but only rotation and translation | imgProcessor/utils/calcAspectRatioFromCorners.py | def calcAspectRatioFromCorners(corners, in_plane=False):
'''
simple and better alg. than below
in_plane -> whether object has no tilt, but only rotation and translation
'''
q = corners
l0 = [q[0, 0], q[0, 1], q[1, 0], q[1, 1]]
l1 = [q[0, 0], q[0, 1], q[-1, 0], q[-1, 1]]
l2 = ... | def calcAspectRatioFromCorners(corners, in_plane=False):
'''
simple and better alg. than below
in_plane -> whether object has no tilt, but only rotation and translation
'''
q = corners
l0 = [q[0, 0], q[0, 1], q[1, 0], q[1, 1]]
l1 = [q[0, 0], q[0, 1], q[-1, 0], q[-1, 1]]
l2 = ... | [
"simple",
"and",
"better",
"alg",
".",
"than",
"below",
"in_plane",
"-",
">",
"whether",
"object",
"has",
"no",
"tilt",
"but",
"only",
"rotation",
"and",
"translation"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/calcAspectRatioFromCorners.py#L8-L32 | [
"def",
"calcAspectRatioFromCorners",
"(",
"corners",
",",
"in_plane",
"=",
"False",
")",
":",
"q",
"=",
"corners",
"l0",
"=",
"[",
"q",
"[",
"0",
",",
"0",
"]",
",",
"q",
"[",
"0",
",",
"1",
"]",
",",
"q",
"[",
"1",
",",
"0",
"]",
",",
"q",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | putTextAlpha | Extends cv2.putText with [alpha] argument | imgProcessor/utils/putTextAlpha.py | def putTextAlpha(img, text, alpha, org, fontFace, fontScale, color,
thickness): # , lineType=None
'''
Extends cv2.putText with [alpha] argument
'''
x, y = cv2.getTextSize(text, fontFace,
fontScale, thickness)[0]
ox, oy = org
imgcut = img... | def putTextAlpha(img, text, alpha, org, fontFace, fontScale, color,
thickness): # , lineType=None
'''
Extends cv2.putText with [alpha] argument
'''
x, y = cv2.getTextSize(text, fontFace,
fontScale, thickness)[0]
ox, oy = org
imgcut = img... | [
"Extends",
"cv2",
".",
"putText",
"with",
"[",
"alpha",
"]",
"argument"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/putTextAlpha.py#L10-L35 | [
"def",
"putTextAlpha",
"(",
"img",
",",
"text",
",",
"alpha",
",",
"org",
",",
"fontFace",
",",
"fontScale",
",",
"color",
",",
"thickness",
")",
":",
"# , lineType=None\r",
"x",
",",
"y",
"=",
"cv2",
".",
"getTextSize",
"(",
"text",
",",
"fontFace",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | fastMean | for bigger ksizes it if often faster to resize an image
rather than blur it... | imgProcessor/filters/fastMean.py | def fastMean(img, f=10, inplace=False):
'''
for bigger ksizes it if often faster to resize an image
rather than blur it...
'''
s0,s1 = img.shape[:2]
ss0 = int(round(s0/f))
ss1 = int(round(s1/f))
small = cv2.resize(img,(ss1,ss0), interpolation=cv2.INTER_AREA)
#bigger
... | def fastMean(img, f=10, inplace=False):
'''
for bigger ksizes it if often faster to resize an image
rather than blur it...
'''
s0,s1 = img.shape[:2]
ss0 = int(round(s0/f))
ss1 = int(round(s1/f))
small = cv2.resize(img,(ss1,ss0), interpolation=cv2.INTER_AREA)
#bigger
... | [
"for",
"bigger",
"ksizes",
"it",
"if",
"often",
"faster",
"to",
"resize",
"an",
"image",
"rather",
"than",
"blur",
"it",
"..."
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/fastMean.py#L5-L19 | [
"def",
"fastMean",
"(",
"img",
",",
"f",
"=",
"10",
",",
"inplace",
"=",
"False",
")",
":",
"s0",
",",
"s1",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"ss0",
"=",
"int",
"(",
"round",
"(",
"s0",
"/",
"f",
")",
")",
"ss1",
"=",
"int",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | read | Build a file path from *paths* and return the contents. | setup.py | def read(*paths):
"""Build a file path from *paths* and return the contents."""
try:
f_name = os.path.join(*paths)
with open(f_name, 'r') as f:
return f.read()
except IOError:
print('%s not existing ... skipping' % f_name)
return '' | def read(*paths):
"""Build a file path from *paths* and return the contents."""
try:
f_name = os.path.join(*paths)
with open(f_name, 'r') as f:
return f.read()
except IOError:
print('%s not existing ... skipping' % f_name)
return '' | [
"Build",
"a",
"file",
"path",
"from",
"*",
"paths",
"*",
"and",
"return",
"the",
"contents",
"."
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/setup.py#L16-L24 | [
"def",
"read",
"(",
"*",
"paths",
")",
":",
"try",
":",
"f_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"*",
"paths",
")",
"with",
"open",
"(",
"f_name",
",",
"'r'",
")",
"as",
"f",
":",
"return",
"f",
".",
"read",
"(",
")",
"except",
"IO... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | averageSameExpTimes | average background images with same exposure time | imgProcessor/camera/DarkCurrentMap.py | def averageSameExpTimes(imgs_path):
'''
average background images with same exposure time
'''
firsts = imgs_path[:2]
imgs = imgs_path[2:]
for n, i in enumerate(firsts):
firsts[n] = np.asfarray(imread(i))
d = DarkCurrentMap(firsts)
for i in imgs:
i = imread(i)
... | def averageSameExpTimes(imgs_path):
'''
average background images with same exposure time
'''
firsts = imgs_path[:2]
imgs = imgs_path[2:]
for n, i in enumerate(firsts):
firsts[n] = np.asfarray(imread(i))
d = DarkCurrentMap(firsts)
for i in imgs:
i = imread(i)
... | [
"average",
"background",
"images",
"with",
"same",
"exposure",
"time"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L46-L58 | [
"def",
"averageSameExpTimes",
"(",
"imgs_path",
")",
":",
"firsts",
"=",
"imgs_path",
"[",
":",
"2",
"]",
"imgs",
"=",
"imgs_path",
"[",
"2",
":",
"]",
"for",
"n",
",",
"i",
"in",
"enumerate",
"(",
"firsts",
")",
":",
"firsts",
"[",
"n",
"]",
"=",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | getLinearityFunction | returns offset, ascent
of image(expTime) = offset + ascent*expTime | imgProcessor/camera/DarkCurrentMap.py | def getLinearityFunction(expTimes, imgs, mxIntensity=65535, min_ascent=0.001,
):
'''
returns offset, ascent
of image(expTime) = offset + ascent*expTime
'''
# TODO: calculate [min_ascent] from noise function
# instead of having it as variable
ascent, offset... | def getLinearityFunction(expTimes, imgs, mxIntensity=65535, min_ascent=0.001,
):
'''
returns offset, ascent
of image(expTime) = offset + ascent*expTime
'''
# TODO: calculate [min_ascent] from noise function
# instead of having it as variable
ascent, offset... | [
"returns",
"offset",
"ascent",
"of",
"image",
"(",
"expTime",
")",
"=",
"offset",
"+",
"ascent",
"*",
"expTime"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L61-L80 | [
"def",
"getLinearityFunction",
"(",
"expTimes",
",",
"imgs",
",",
"mxIntensity",
"=",
"65535",
",",
"min_ascent",
"=",
"0.001",
",",
")",
":",
"# TODO: calculate [min_ascent] from noise function\r",
"# instead of having it as variable\r",
"ascent",
",",
"offset",
",",
"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | sortForSameExpTime | return image paths sorted for same exposure time | imgProcessor/camera/DarkCurrentMap.py | def sortForSameExpTime(expTimes, img_paths): # , excludeSingleImg=True):
'''
return image paths sorted for same exposure time
'''
d = {}
for e, i in zip(expTimes, img_paths):
if e not in d:
d[e] = []
d[e].append(i)
# for key in list(d.keys()):
# if ... | def sortForSameExpTime(expTimes, img_paths): # , excludeSingleImg=True):
'''
return image paths sorted for same exposure time
'''
d = {}
for e, i in zip(expTimes, img_paths):
if e not in d:
d[e] = []
d[e].append(i)
# for key in list(d.keys()):
# if ... | [
"return",
"image",
"paths",
"sorted",
"for",
"same",
"exposure",
"time"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L83-L98 | [
"def",
"sortForSameExpTime",
"(",
"expTimes",
",",
"img_paths",
")",
":",
"# , excludeSingleImg=True):\r",
"d",
"=",
"{",
"}",
"for",
"e",
",",
"i",
"in",
"zip",
"(",
"expTimes",
",",
"img_paths",
")",
":",
"if",
"e",
"not",
"in",
"d",
":",
"d",
"[",
... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | getDarkCurrentAverages | return exposure times, image averages for each exposure time | imgProcessor/camera/DarkCurrentMap.py | def getDarkCurrentAverages(exposuretimes, imgs):
'''
return exposure times, image averages for each exposure time
'''
x, imgs_p = sortForSameExpTime(exposuretimes, imgs)
s0, s1 = imgs[0].shape
imgs = np.empty(shape=(len(x), s0, s1),
dtype=imgs[0].dtype)
for i, i... | def getDarkCurrentAverages(exposuretimes, imgs):
'''
return exposure times, image averages for each exposure time
'''
x, imgs_p = sortForSameExpTime(exposuretimes, imgs)
s0, s1 = imgs[0].shape
imgs = np.empty(shape=(len(x), s0, s1),
dtype=imgs[0].dtype)
for i, i... | [
"return",
"exposure",
"times",
"image",
"averages",
"for",
"each",
"exposure",
"time"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L101-L115 | [
"def",
"getDarkCurrentAverages",
"(",
"exposuretimes",
",",
"imgs",
")",
":",
"x",
",",
"imgs_p",
"=",
"sortForSameExpTime",
"(",
"exposuretimes",
",",
"imgs",
")",
"s0",
",",
"s1",
"=",
"imgs",
"[",
"0",
"]",
".",
"shape",
"imgs",
"=",
"np",
".",
"emp... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | getDarkCurrentFunction | get dark current function from given images and exposure times | imgProcessor/camera/DarkCurrentMap.py | def getDarkCurrentFunction(exposuretimes, imgs, **kwargs):
'''
get dark current function from given images and exposure times
'''
exposuretimes, imgs = getDarkCurrentAverages(exposuretimes, imgs)
offs, ascent, rmse = getLinearityFunction(exposuretimes, imgs, **kwargs)
return offs, ascent, ... | def getDarkCurrentFunction(exposuretimes, imgs, **kwargs):
'''
get dark current function from given images and exposure times
'''
exposuretimes, imgs = getDarkCurrentAverages(exposuretimes, imgs)
offs, ascent, rmse = getLinearityFunction(exposuretimes, imgs, **kwargs)
return offs, ascent, ... | [
"get",
"dark",
"current",
"function",
"from",
"given",
"images",
"and",
"exposure",
"times"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L118-L124 | [
"def",
"getDarkCurrentFunction",
"(",
"exposuretimes",
",",
"imgs",
",",
"*",
"*",
"kwargs",
")",
":",
"exposuretimes",
",",
"imgs",
"=",
"getDarkCurrentAverages",
"(",
"exposuretimes",
",",
"imgs",
")",
"offs",
",",
"ascent",
",",
"rmse",
"=",
"getLinearityFu... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | alignImageAlongLine | return a sub image aligned along given line
@param img - numpy.2darray input image to get subimage from
@param line - list of 2 points [x0,y0,x1,y1])
@param height - height of output array in y
@param length - width of output array
@param zoom - zoom factor
@param fast - speed up calcul... | imgProcessor/transform/alignImageAlongLine.py | def alignImageAlongLine(img, line, height=15, length=None,
zoom=1, fast=False, borderValue=0):
'''
return a sub image aligned along given line
@param img - numpy.2darray input image to get subimage from
@param line - list of 2 points [x0,y0,x1,y1])
@param height - he... | def alignImageAlongLine(img, line, height=15, length=None,
zoom=1, fast=False, borderValue=0):
'''
return a sub image aligned along given line
@param img - numpy.2darray input image to get subimage from
@param line - list of 2 points [x0,y0,x1,y1])
@param height - he... | [
"return",
"a",
"sub",
"image",
"aligned",
"along",
"given",
"line"
] | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/alignImageAlongLine.py#L10-L60 | [
"def",
"alignImageAlongLine",
"(",
"img",
",",
"line",
",",
"height",
"=",
"15",
",",
"length",
"=",
"None",
",",
"zoom",
"=",
"1",
",",
"fast",
"=",
"False",
",",
"borderValue",
"=",
"0",
")",
":",
"height",
"=",
"int",
"(",
"round",
"(",
"height"... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
train | positionToIntensityUncertainty | calculates the estimated standard deviation map from the changes
of neighbouring pixels from a center pixel within a point spread function
defined by a std.dev. in x and y taken from the (sx, sy) maps
sx,sy -> either 2d array of same shape as [image]
of single values | imgProcessor/uncertainty/positionToIntensityUncertainty.py | def positionToIntensityUncertainty(image, sx, sy, kernelSize=None):
'''
calculates the estimated standard deviation map from the changes
of neighbouring pixels from a center pixel within a point spread function
defined by a std.dev. in x and y taken from the (sx, sy) maps
sx,sy -> either 2d ... | def positionToIntensityUncertainty(image, sx, sy, kernelSize=None):
'''
calculates the estimated standard deviation map from the changes
of neighbouring pixels from a center pixel within a point spread function
defined by a std.dev. in x and y taken from the (sx, sy) maps
sx,sy -> either 2d ... | [
"calculates",
"the",
"estimated",
"standard",
"deviation",
"map",
"from",
"the",
"changes",
"of",
"neighbouring",
"pixels",
"from",
"a",
"center",
"pixel",
"within",
"a",
"point",
"spread",
"function",
"defined",
"by",
"a",
"std",
".",
"dev",
".",
"in",
"x",... | radjkarl/imgProcessor | python | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/positionToIntensityUncertainty.py#L52-L87 | [
"def",
"positionToIntensityUncertainty",
"(",
"image",
",",
"sx",
",",
"sy",
",",
"kernelSize",
"=",
"None",
")",
":",
"psf_is_const",
"=",
"not",
"isinstance",
"(",
"sx",
",",
"np",
".",
"ndarray",
")",
"if",
"not",
"psf_is_const",
":",
"assert",
"image",... | 7c5a28718f81c01a430152c60a686ac50afbfd7c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.