本文整理汇总了Python中SeaGoatVision.commons.param.Param.get_pos_list方法的典型用法代码示例。如果您正苦于以下问题:Python Param.get_pos_list方法的具体用法?Python Param.get_pos_list怎么用?Python Param.get_pos_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SeaGoatVision.commons.param.Param
的用法示例。
在下文中一共展示了Param.get_pos_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HDR
# 需要导入模块: from SeaGoatVision.commons.param import Param [as 别名]
# 或者: from SeaGoatVision.commons.param.Param import get_pos_list [as 别名]
#.........这里部分代码省略.........
"""
SOURCE: https://sites.google.com/site/bpowah/hdrandpythonpil
a collection of images to merge into HDR
blend an arbitrary number of photos into a single HDR image
or several images with various combinations of HDR parameters
it is assumed that project folders contain all the images you want to merge
case = folder name
cur_dir = folder where the project folders are located
images are auto-sorted by degree of exposure (image brightness)
"""
def get_masks(self, imgs, cur_str):
"""
create a set of masks from a list of images
(one mask for every adjacent pair of images
"""
masks = []
mask_ct = len(imgs) - 1
imgs = [self.bal(img.convert(mode='L'), cur_str) for img in imgs]
for i in range(mask_ct):
blend_fraction = .5 # 1. - (float(i)+.5)/float(mask_ct)
m = Image.blend(imgs[i], imgs[i + 1], blend_fraction)
masks.append(m)
return masks
def bal(self, im, cur_str):
"""
adjust the balance of the mask
(re-distribute the histogram so that there are more
extreme blacks and whites)
like increasing the contrast, but without clipping
and maintains overall average image brightness
"""
h = im.histogram()
ln = range(len(h))
up = [sum(h[0: i]) for i in ln]
lo = [sum(h[i:-1]) for i in ln]
ct = sum(h)
st = int(cur_str * 255.)
lut = [i + st * up[i] * lo[i] * (up[i] - lo[i]) / ct ** 3 for i in ln]
for i in ln:
if lut[i] < 1:
lut[i] = 1
if lut[i] > 255:
lut[i] = 255
return im.point(lut)
def merge(self, imgs, cur_str):
"""
combine a set images into a smaller set by combinding all
adjacent images
"""
masks = self.get_masks(imgs, cur_str)
imx = lambda i: Image.composite(imgs[i], imgs[i + 1], masks[i])
return [imx(i) for i in range(len(masks))]
def merge_all(self, imgs, cur_str):
"""
iteratively merge a set of images until only one remains
"""
while len(imgs) > 1:
imgs = self.merge(imgs, cur_str)
return imgs[0]
def get_hdr(self, images, strength=0.0, naturalness=1.0):
"""
process the hdr image(s)
strength - a float that defines how strong the hdr
effect should be
- a value of zero will combine images by using a
greyscale image average
- a value greater than zero will use higher contrast
versions of those greyscale images
- suggest you a value between 0.0 and 2.0
naturalness - values between zero and one
- zero will be a very high-contrast image
- 1.0 will be a very flat image
- 0.7 to 0.9 tend to give the best results
"""
imgs = copy([Image.fromarray(img) for img in images])
sat_img = self.merge_all(imgs, strength)
if self.debug_show.get_pos_list() == 1:
return np.array(sat_img)
imgs.reverse()
con_img = self.merge_all(imgs, strength)
if self.debug_show.get_pos_list() == 2:
return np.array(con_img)
"""
combines a saturated image with a contrast image
and puts them in a dictionary of completed images
"""
images = Image.blend(con_img, sat_img, naturalness)
images = np.array(images)
return images