Remove Unused Texture Files?

I have created a 3D textured model of a sculpture. The downloaded .obj model has 234 texture files associated with it. Much of the model is extraneous background. I have deleted the parts of the model I don’t want using Blender. However, the 234 texture files are still referenced. Even after converting these files from PNG to JPG files, the result is too large to upload to Sketchfab.

As I have removed a very significant portion of the model, it is almost certain that some (many) of these texture files are no longer needed. I have spent hours of unsuccessful searching for how to remove these unneeded texture files so I can reduce the size for uploading to Sketchfab.

I’ve looked at MeshLab and Blender. I suspect it can be done with Python scripting in Blender, but have not come across the solution. I’m a pretty low level user with both of these programs. Has anyone come across a way to resolve this?

Thank you!

2 Likes

Take a look at remeshing approaches that include transferring the texture from the original mesh to the remeshed version (blender).

I haven’t found any fully written out tutorials on it, but there are endless videos on YouTube on remesh with texture transfer. That will ensure only the necessary are in your new mesh.

1 Like

Try enabling --texturing-single-material

3 Likes

Piero, thank you for your suggestion. I re-ran using --texturing-single-material, and still ended up with 234 texture files. I see that the first one is huge (795MB), presumably containing all of the texture data. When I convert this to JPG format, it alone is 142MB, which doesn’t solve my problem of getting the final size of all files to under 100MB for upload to Sketchfab. That aside, why are there still 234 texture files instead of 1? I admit, I do not fully understand how texturing works, beyond the concept of mapping flat (2D) textures onto a 3D object.

Hi Gary.

Faced with more or less exactly the same problem, on Ubuntu I run a small script that converts the ODM texture files from PNG to JPG but also reduce the resolution to 50% in both dimensions. Of course you could reduce the size by even more but 50% has worked pretty well for me and the end result is close enough (for my purposes at least) to the original.

Something like this, with convert being part of the ImageMagick package.

convert input.png -resize 50% output.jpg

In one or two cases where the above approach wasn’t quite enough I also used the Meshlab option to reduce the number of faces although obviously this might reduce the quality by too much.

2 Likes

Another possibility that I have used successfully in the past is to do the cropping of the model before the actual texturing stage. That way unwanted textures are not even created in the first place.
In my case I did this, not for removing unused textures, but to actually crop the model.

That means after the meshing stage is done, I search for the odm_mesh.ply within the docker files. Copy that to a local directory where I can then work on it with for example Blender.
Once I cropped and possibly sculpted it the way I want, I copy it back into the docker filesystem and continue or re-run the process   From Texturing.
Off course, make sure to keep the filename, since ODM will otherwise redo the meshing stage.

That way ODM will only create the textures for the model that I want.

Only downside is that I have to do this during or shortly after a process ran. NodeODM deletes process files after 2 days, if not configured to keep them longer.
ODM keeps the process files, but has to be run in a terminal.

Meshroom like ODM uses openSfM and openMVS but keeps the process files in a cache folder until deleted by the user to be able to rerun every stage. I also saw (but haven’t used) other photogrammetry software (like Agisoft’s Metashape) that also allows the user to go back to the process files, alter them, and continue with the process. In case of Metashape all while staying in the same GUI.
Might at some point also be interesting for WebODM to offer a possibility to manually work on the intermediate/process files :wink:
I wouldn’t mind to change UI for altering the files (using Blender to work on meshes or CloudCompare to work on point clouds), but an easier way to work on and keep the process files would actually simplify many steps for me.

With Meshroom I can copy the cache folder, to have alternative versions of the same project. Which also enables me to “undo” steps.

But, back to topic:
Best way to remove unused texture files is to not create them in the first place :cowboy_hat_face:
That can also shorten the run time of a process.

 

I :heart: that option even if it doesn’t remove unwanted textures. But it’s nice to have and I am considering to make it default for my runs.

4 Likes

@SeeNoEvil, I frequently reduce the size of the texture files by converting them to JPGs. In this case, that wasn’t enough. I’ve also decimated the mesh in Blender, but again, that wasn’t enough.

@shiva, I managed to succeed by taking the intermediate files after sky masking - sky-removal:true (I have my Windows native installation modified to keep files for 30 days) and manually roughly masking out most of the background from ~287 mask files. the bg-removal option didn’t clean up the background adequately, which is no surprise with this subject. This got the resultant textured mesh total size small enough that I could upload it to Sketchfab.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.