当前位置: 首页>>代码示例>>Python>>正文


Python PNMImage.set_xel方法代码示例

本文整理汇总了Python中panda3d.core.PNMImage.set_xel方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.set_xel方法的具体用法?Python PNMImage.set_xel怎么用?Python PNMImage.set_xel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.core.PNMImage的用法示例。


在下文中一共展示了PNMImage.set_xel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_noise_tex

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_xel [as 别名]
 def _load_noise_tex(self):
     """ Loads the default 4x4 noise tex """
     random.seed(42)
     img = PNMImage(4, 4, 3)
     for x in range(16):
         img.set_xel(x%4, x//4, random.random(), random.random(), random.random())
     tex = Texture("Random4x4")
     tex.load(img)
     self._pipeline.stage_mgr.add_input("Noise4x4", tex)
开发者ID:wdmwdm,项目名称:RenderPipeline,代码行数:11,代码来源:CommonResources.py

示例2: create_noise_textures

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_xel [as 别名]
 def create_noise_textures(self):
     # Always generate the same random textures
     seed(42)
     img = PNMImage(4, 4, 3)
     for x in range(4):
         for y in range(4):
             img.set_xel(x, y, random(), random(), random())
     tex = Texture("Rand4x4")
     tex.load(img)
     self._target.set_shader_input("Noise4x4", tex)
开发者ID:MYheavyGo,项目名称:RenderPipeline,代码行数:12,代码来源:AOStage.py

示例3: generate_dataset_texture_into

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_xel [as 别名]
    def generate_dataset_texture_into(self, dest_tex, z):
        resolution_vertical = dest_tex.get_y_size()
        resolution_horizontal = dest_tex.get_x_size()

        dest = PNMImage(resolution_vertical, resolution_horizontal, 1, 65535)

        for vert in range(resolution_vertical):
            for horiz in range(resolution_horizontal):
                vert_angle = vert / (resolution_vertical-1.0)
                vert_angle = math.cos(vert_angle * math.pi) * 90.0 + 90.0
                horiz_angle = horiz / (resolution_horizontal-1.0) * 360.0
                candela = self.get_candela_value(vert_angle, horiz_angle)
                dest.set_xel(vert, horiz, candela)

        dest_tex.load(dest, z, 0)
开发者ID:wdmwdm,项目名称:RenderPipeline,代码行数:17,代码来源:IESDataset.py

示例4: enumerate

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_xel [as 别名]
            for i, s_nxv in enumerate(reversed(nxv_values)):
                if NxV >= s_nxv:
                    index = i
                    break
            index = len(nxv_values) - index - 1
            next_index = index + 1 if index < dest_size - 1 else index

            curr_nxv = nxv_values[index]
            next_nxv = nxv_values[next_index]

            lerp_factor = (NxV - curr_nxv) / max(1e-10, abs(next_nxv - curr_nxv))
            lerp_factor = max(0.0, min(1.0, lerp_factor))
            indices.append((index, next_index, lerp_factor))

        # Generate the final linear lut using the lerp weights
        for y in xrange(dest_h):
            for x in xrange(dest_size):
                curr_i, next_i, lerp = indices[x]
                curr_v = img.get_xel(curr_i, y)
                next_v = img.get_xel(next_i, y)
                dest.set_xel(x, y, curr_v * (1 - lerp) + next_v * lerp)


        out_name = config["out_name"].replace("{}", str(pass_index))
        dest.write(config["out_dir"] + "/" + out_name)

try:
    os.remove("scene.png")
except:
    pass
开发者ID:ELMERzark,项目名称:RenderPipeline,代码行数:32,代码来源:generate_reference.py

示例5: PNMImage

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_xel [as 别名]
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
 	 	    	 	
"""
from __future__ import division, print_function

import math
from panda3d.core import PNMImage

lut_size = 64
lut_cols = 8
lut_rows = (lut_size + lut_cols - 1) // lut_cols

img = PNMImage(lut_size * lut_cols, lut_size * lut_rows, 3, 2**16 - 1)

def to_linear(v):
    return float(v) / float(lut_size-1)

def to_linear_inv(v):
    return 1 - to_linear(v)

for r in range(lut_size):
    for g in range(lut_size):
        for b in range(lut_size):
            slice_offset_x = (b % lut_cols) * lut_size
            slice_offset_y = (b // lut_cols) * lut_size
            img.set_xel(r + slice_offset_x, g + slice_offset_y, 
                to_linear(r), to_linear_inv(g), to_linear(b))

img.write("DefaultLUT.png")
开发者ID:MYheavyGo,项目名称:RenderPipeline,代码行数:32,代码来源:generate_default_lut.py

示例6: xrange

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_xel [as 别名]
            for k in xrange(3):
                values[k].append(srgb_to_linear(line[k]))

        def to_linear(v):
            return float(v) / float(64 - 1)

        def to_linear_inv(v):
            return 1 - to_linear(v)

        def lookup_value(v, values):
            return values[int(v * (len(values) - 1))]

        # Generate lut
        img = PNMImage(64 * 8, 64 * 8, 3, 2**16 - 1)
        for r in xrange(64):
            for g in xrange(64):
                for b in xrange(64):
                    slice_offset_x = (b % 8) * 64
                    slice_offset_y = (b // 8) * 64

                    fr, fg, fb = to_linear(r), to_linear_inv(g), to_linear(b)

                    fr = lookup_value(fr, values[0])
                    fg = lookup_value(fg, values[1])
                    fb = lookup_value(fb, values[2])

                    img.set_xel(r + slice_offset_x, g + slice_offset_y, fr, fg, fb)

        img.write("film_luts/" + output_name + ".png")
开发者ID:ELMERzark,项目名称:RenderPipeline,代码行数:31,代码来源:generate_film_luts.py

示例7: PNMImage

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import set_xel [as 别名]
write_diff_img = False

img_a = PNMImage(source_a)
img_b = PNMImage(source_b)

w, h = img_a.get_x_size(), img_a.get_y_size()
img_dest = PNMImage(w, h, 3)

error_scale = 10.0

total_diff = 0.0

for x in xrange(w):
    for y in xrange(h):
        val_a = img_a.get_xel(x, y)
        val_b = img_b.get_xel(x, y)

        abs_diff = (val_a - val_b) * error_scale
        r, g, b = abs(abs_diff.x), abs(abs_diff.y), abs(abs_diff.z)

        img_dest.set_xel(x, y, r, g, b)
        total_diff += r + g + b

total_diff /= float(w * h)
total_diff /= error_scale

print("Average difference: ", total_diff, " in RGB: ", total_diff * 255)

img_dest.write("difference.png")
开发者ID:croxis,项目名称:SpaceDrive,代码行数:31,代码来源:generate_difference.py


注:本文中的panda3d.core.PNMImage.set_xel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。