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


Python PNMImage.get_xel方法代码示例

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


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

示例1: __init__

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import get_xel [as 别名]
    def __init__(self):

        # Setup window size, title and so on
        load_prc_file_data("", """
        win-size 1600 900
        window-title Render Pipeline - Benchmark
        """)

        # ------ Begin of render pipeline code ------

        # Insert the pipeline path to the system path, this is required to be
        # able to import the pipeline classes
        pipeline_path = "../../"

        # Just a special case for my development setup, so I don't accidentally
        # commit a wrong path. You can remove this in your own programs.
        if not os.path.isfile(os.path.join(pipeline_path, "setup.py")):
            pipeline_path = "../../RenderPipeline/"

        sys.path.insert(0, pipeline_path)

        from rpcore import RenderPipeline, PointLight
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)

        # This is a helper class for better camera movement - its not really
        # a rendering element, but it included for convenience
        from rpcore.util.movement_controller import MovementController

        # ------ End of render pipeline code, thats it! ------

        # Set time of day
        self.render_pipeline.daytime_mgr.time = "17:41"

        self.camLens.set_fov(90)

        model = self.loader.load_model("scene/Scene.bam")
        model.reparent_to(self.render)

        model.flatten_strong()
        num_rows = 255

        img = PNMImage("scene/lights.png")

        for x in range(num_rows):
            for y in range(num_rows):
                light = PointLight()
                # light.direction = (0, 0, -1)
                # light.fov = 60
                # light.set_color_from_temperature(randint(2000, 20000))
                light.color = img.get_xel(x * 1, y * 1)
                light.energy = 5000 * (x / num_rows)
                light.pos = Vec3(-(x - num_rows // 2) / num_rows * 1000.0,
                                 (y - num_rows // 2) / num_rows * 1000.0, 2)
                light.radius = 4
                light.inner_radius = 0.5
                light.casts_shadows = False
                light.shadow_map_resolution = 256
                self.render_pipeline.add_light(light)

        self.render_pipeline.prepare_scene(model)

        # Init movement controller
        self.controller = MovementController(self)
        self.controller.set_initial_position(Vec3(0, 450, 200), Vec3(0))
        self.controller.setup()

        self.accept("l", self.benchmark)
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:70,代码来源:main.py

示例2: enumerate

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import get_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

示例3: PNMImage

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import get_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

示例4: approx

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import get_xel [as 别名]
from __future__ import division, print_function

from panda3d.core import PNMImage, Vec3


def approx(roughness):
    return 1.0 - 0.5 * roughness

for i in range(11):
    r = i / 10.0
    fname = "batch_compare/Gold-R" + str(r) + ".png"

    img = PNMImage(fname)
    # color = (img.get_xel(img.get_x_size() // 2 + 3, img.get_y_size() // 2))
    color = (img.get_xel(256, 47))

    color.x = pow(color.x, 2.2)
    color.y = pow(color.y, 2.2)
    color.z = pow(color.z, 2.2)

    # print(color)

    basecolor = Vec3(1, 0.867136, 0.358654)

    ref_r, apprx_r = color.x, approx(r) * (0.5 + 0.5 * basecolor.x)
    ref_g, apprx_g = color.y, approx(r) * (0.5 + 0.5 * basecolor.y)
    ref_b, apprx_b = color.z, approx(r) * (0.5 + 0.5 * basecolor.z)
    print("Roughness:", r, ", color = ", ref_r, ref_g, ref_b, "vs", apprx_r, apprx_g, apprx_b)
    l = abs(ref_r - apprx_r) + abs(ref_g - apprx_g) + abs(ref_b - apprx_b)
    print("  --> ", l)
开发者ID:ELMERzark,项目名称:RenderPipeline,代码行数:32,代码来源:get_brightness.py

示例5: approx

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import get_xel [as 别名]
from __future__ import division, print_function
def approx(roughness):
    alpha = roughness * roughness
    return 1.0 - 0.5 * roughness
from panda3d.core import PNMImage, Vec3
import os
for i in range(11):
    r = i / 10.0
    fname = "batch_compare/Gold-R" + str(r) + ".png"
    img = PNMImage(fname)
    # color = (img.get_xel(img.get_x_size() // 2 + 3, img.get_y_size() // 2))
    color = (img.get_xel(256, 47))
    color.x = pow(color.x, 2.2)
    color.y = pow(color.y, 2.2)
    color.z = pow(color.z, 2.2)
    # print(color)
    basecolor = Vec3(1, 0.867136, 0.358654)
    ref_r, apprx_r = color.x, approx(r) * (0.5 + 0.5 * basecolor.x)
    ref_g, apprx_g = color.y, approx(r) * (0.5 + 0.5 * basecolor.y)
    ref_b, apprx_b = color.z, approx(r) * (0.5 + 0.5 * basecolor.z)
    print("Roughness:", r, ", color = ", ref_r, ref_g, ref_b, "vs", apprx_r, apprx_g, apprx_b)
    l = abs(ref_r - apprx_r) + abs(ref_g - apprx_g) + abs(ref_b - apprx_b)
    print("  --> ", l)
    # print("Roughness:", r, ", color = ", ref, "vs", apprx, " =\t", abs(ref - apprx) * 100.0)
开发者ID:aimoonchen,项目名称:RenderPipeline,代码行数:26,代码来源:get_brightness.py


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