Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to store a scalar function of a mesh as an image? #38

Open
majia67 opened this issue Apr 30, 2018 · 12 comments
Open

How to store a scalar function of a mesh as an image? #38

majia67 opened this issue Apr 30, 2018 · 12 comments

Comments

@majia67
Copy link

majia67 commented Apr 30, 2018

I'm doing the remeshing project, and in this project it requires to store the "control map" as a 2D image and applying error diffusion technique to do the resampling. After that, it requires to read the result image and recover it as a point cloud. I'm wondering is there a corresponding function in libigl or its external libraries?

@jiangzhongshi
Copy link
Collaborator

Please correct me if I am wrong. I don't think you actually need a rasterized image (with fixed pixels etc.), instead, you are sampling in a square region, without the need of pixel-level information, then project them back to the surface.

Just FYI, interacting with images can be done through this tutorial http://libigl.github.io/libigl/tutorial/tutorial.html#screencapture

@majia67
Copy link
Author

majia67 commented Apr 30, 2018

The paper does the rasterization and use error diffusion to do the re-sampling. Are you suggesting that I could complete this step without using error diffusion? In that case, is there efficient sampling technique for a scalar function defined on a mesh?

@jiangzhongshi
Copy link
Collaborator

Sorry I wasn't reading it carefully. In this case, I am not aware of cpu-side rasterization functions in libigl, probably you can implement it. Or you can also consider grabbing the opengl buffer.

@majia67
Copy link
Author

majia67 commented Apr 30, 2018

@jiangzhongshi Thank you for your suggestion, but I'm not sure if these could be done in less than two weeks... If there any alternative sampling techniques (preferably can work on the mesh directly)? Basically I just want a sampling algorithm that could distribute the vertices according to the control map (a scalar function defined on the mesh).

@jiangzhongshi
Copy link
Collaborator

I see it in the paper, they were using OpenGL. This involves calling the API glReadPixels, I don't have a specific example at hand. Alternatively, you can implement pixel-by-pixel, it is slower, but easy to implement.

@danielepanozzo
Copy link
Owner

Hi,

you can use libigl for doing the rasterization, take a look at:
http://libigl.github.io/libigl/tutorial/607_ScreenCapture/main.cpp . '1' saves the image to a memory buffer, i.e. it rasterizes a triangle mesh into an array of pixels, which is exactly what you need.

For the half-toning, it is not in libigl: you will have to implement that part.

@majia67
Copy link
Author

majia67 commented May 1, 2018

Thank you for your suggestions!

@majia67
Copy link
Author

majia67 commented May 2, 2018

@danielepanozzo Hi professor, I tried to use the example you mentioned, and I want to save the buffer into a png file. My program can be built successfully but won't run. It shows the following error message:

The code execution cannot proceed because igl_stb_image.dll was not found. Reinstalling the program may fix this problem.

I did enabled using PNG module in my CMakeLists.txt and add igl::png in target_link_libraries. Is this a bug in libigl or I didn't do the right configuration?

@jiangzhongshi
Copy link
Collaborator

Does the tutorial work with a vanilla libigl build? If it doesn't, then it's likely to be a bug in libigl's CMake configurations.

@majia67
Copy link
Author

majia67 commented May 3, 2018

@jiangzhongshi Same error. It is likely to be a libigl bug now. I will report it in libigl repository.

@jiangzhongshi
Copy link
Collaborator

As a temporary workaround, if you are playing around with matrices RGB, you don't need to export it. If you do, maybe you can use this https://github.com/danielepanozzo/cg/blob/master/Assignment_1/src/stb_image_write.h

@majia67
Copy link
Author

majia67 commented May 3, 2018

Thank you for your suggestion! A fix is also given in libigl/libigl#758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants