mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.1k stars 246 forks source link

aov index problem #1125

Closed YanQiSun closed 7 months ago

YanQiSun commented 7 months ago

I used the shape_index function of aov, but I didn't find out how to distinguish and identify different objects. My xml scene is as follows.

<scene version="2.1.0">

<!-- Defaults, these can be set via the command line: -Darg=value -->

    <default name="spp" value="1024"/>
    <default name="resx" value="512"/>
    <default name="resy" value="512"/>

<!-- Camera and Rendering Parameters -->

    <integrator type="aov">
        <string name="aovs" value="dd.y:depth,nn:geo_normal,index:shape_index"/>

    </integrator>

    <sensor type="perspective" id="elm__2" name="elm__2">
        <string name="fov_axis" value="x"/>
        <float name="fov" value="39.597745"/>
        <float name="principal_point_offset_x" value="0.000000"/>
        <float name="principal_point_offset_y" value="-0.000000"/>
        <float name="near_clip" value="0.100000"/>
        <float name="far_clip" value="1000.000000"/>
        <transform name="to_world">
            <rotate x="1" angle="22.274527543880957"/>
            <rotate y="1" angle="-54.18294470451111"/>
            <rotate z="1" angle="11.803913286822173"/>
            <translate value="3.855098 3.181333 -3.171851"/>
        </transform>
        <sampler type="independent" name="sampler">
            <integer name="sample_count" value="$spp"/>
        </sampler>
        <film type="hdrfilm" name="film">
            <integer name="width" value="$resx"/>
            <integer name="height" value="$resy"/>
        </film>
    </sensor>

<!-- Materials -->

    <bsdf type="twosided" id="default-bsdf" name="default-bsdf">
        <bsdf type="diffuse" name="bsdf"/>
    </bsdf>
<!-- 
    <bsdf type="polarizer" id="polarizer_material">
        <float name="theta" value="45"/> 
    </bsdf> -->

<!-- Emitters -->

    <emitter type="point" id="elm__5" name="elm__5">
        <point name="position" x="0.0" y="7.599999904632568" z="0.0"/>
        <rgb value="390 390 390" name="intensity"/>
    </emitter>

<!-- Shapes -->

    <shape type="ply" id="elm__4" name="elm__4">
        <string name="filename" value="meshes/SmallCube.ply"/>
        <boolean name="face_normals" value="true"/>
        <ref id="default-bsdf" name="bsdf"/>
    </shape>
    <shape type="ply" id="elm__6" name="elm__6">
        <string name="filename" value="meshes/Ground.ply"/>
        <boolean name="face_normals" value="true"/>
        <ref id="default-bsdf" name="bsdf"/>
    </shape>

    <shape type="ply" id="elm__7" name="elm__7">
        <string name="filename" value="/media/sun/TOSHIBA EXT/3dpoint/carrot/train/good/ply/000.ply"/>
        <boolean name="face_normals" value="true"/>

        <bsdf type="diffuse">
            <texture type="mesh_attribute" name="reflectance">
                <string name="name" value="vertex_color"/>
            </texture>
        </bsdf>

        <transform name="to_world">

            <scale value="20, 20, 20"/>

        </transform>

    </shape>

<!-- Volumes -->

</scene>

What should I do if I just want to segment ele_7?

import matplotlib.pyplot as plt

res = dict(bitmap.split())
print(res.keys())

array = np.array(bitmap, copy=False) 

# (dd.y.T)
plt.figure()
plt.imshow(array[:, :, 0], cmap='gray')
plt.colorbar()
plt.title('Depth')

#(X, Y, Z)
normal_map = np.mean(array[:, :, 1:4], axis=2)
plt.figure()
plt.imshow(normal_map, cmap='coolwarm')
plt.colorbar()
plt.title('Normal Map')

# (index.I)
plt.figure()
plt.imshow(array[:, :, 4], cmap='viridis')
plt.colorbar()
plt.title('Index')

plt.show()

Or how to get the index of ele-7

YanQiSun commented 7 months ago

solved

merlinND commented 7 months ago

Hello @YanQiSun,

Could you please share your solution for others who may run into this post later?