How to visualize .surface.mat file

36 Views Asked by At

Trying to open HS_224b_GMOCF_r1.50_n4_v512.surface.mat file which I download at here. I assume this is a 3d scan of a tablet. I couldn't find a way to display it.

I tried the following options:


# Load the .mat file
with h5py.File('/home/*/HS_224b_GMOCF_r1.50_n4_v512.surface.mat', 'r') as file:
    # Access and manipulate the data as needed
    # For example, if you have 'vertices' and 'faces' datasets:
    vertices = file['vertices'][:]
    faces = file['faces'][:]

# Now you can visualize the data or perform further operations
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Create a 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Plot the surface
ax.plot_trisurf(vertices[:, 0], vertices[:, 1], vertices[:, 2], triangles=faces, cmap='viridis')

# Customize the plot as needed
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('Surface Visualization')

# Show the plot
plt.show()

raise error;

Traceback (most recent call last):
  File "/home/*/mat.py", line 4, in <module>
    with h5py.File('/home/*/HS_224b_GMOCF_r1.50_n4_v512.surface.mat', 'r') as file:
  File "/home/*/.pyenv/versions/3.8.13/envs/*/lib/python3.8/site-packages/h5py/_hl/files.py", line 567, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
  File "/home/*/.pyenv/versions/3.8.13/envs/*/lib/python3.8/site-packages/h5py/_hl/files.py", line 231, in make_fid
    fid = h5f.open(name, flags, fapl=fapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 106, in h5py.h5f.open
OSError: Unable to open file (file signature not found)
import scipy.io

# Load the .mat file
data = scipy.io.loadmat('/home/*/HS_224b_GMOCF_r1.50_n4_v512.surface.mat')

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Assuming 'vertices' and 'faces' are the relevant data in your .mat file
vertices = data['vertices']
faces = data['faces']

# Create a 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Plot the surface
ax.plot_trisurf(vertices[:, 0], vertices[:, 1], vertices[:, 2], triangles=faces, cmap='viridis')

# Customize the plot as needed
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('Surface Visualization')

# Show the plot
plt.show()

gives the following error;

Traceback (most recent call last):
  File "/home/*/mat.py", line 4, in <module>
    data = scipy.io.loadmat('/home/*/HS_224b_GMOCF_r1.50_n4_v512.surface.mat')
  File "/home/*/.pyenv/versions/3.8.13/envs/*/lib/python3.8/site-packages/scipy/io/matlab/_mio.py", line 226, in loadmat
    MR, _ = mat_reader_factory(f, **kwargs)
  File "/home/*/.pyenv/versions/3.8.13/envs/*/lib/python3.8/site-packages/scipy/io/matlab/_mio.py", line 74, in mat_reader_factory
    mjv, mnv = _get_matfile_version(byte_stream)
  File "/home/*/.pyenv/versions/3.8.13/envs/*/lib/python3.8/site-packages/scipy/io/matlab/_miobase.py", line 251, in _get_matfile_version
    raise ValueError('Unknown mat file type, version %s, %s' % ret)
ValueError: Unknown mat file type, version 51, 51
0

There are 0 best solutions below