saving image in binary

Dear community members,

I do not want to save the entire screenshot of my sliced microstructure.

Is there a way to save only the sliced microstructure as binary image using pvpython?

I hope I will find my answer here.

Thank you for the great support

Best regards,
Hesham Salama

This is unclear. Please add a screenshot of what you are trying to do.

Here is the sliced microstructure, how to save this as a binary image without the background, just the microstructure?

File → Save Data → PNG

There is no PNG or any other image format in save data

Good point, you can’t save a polydata as a .png. I’m not sure this is possible without a custom filter.

So, according to your answer, there is no way to save the image as data but only as a screenshot and then crop it by any other means. Is that correct?

It would be technically possible to use Resample To Image to resample your polydata to a 2D image (make the 3rd dimension size 1). From there you could theoretically save as a PNG.

But the PNG file format is pretty limited. It can only accept certain types of data, so there is a good chance the save will fail anyway. It may take some custom processing to get the field data to a form that is acceptable to PNG.

@Kenneth_Moreland : I’ve never been able to use RessampleToImage with a slice. I’m planning to open an issue at some point but more investigation is needed.

Oh, yeah. There is that floating point issue of the sample points lying exactly in the plane of the polygons. I think it works out OK if you have a slice exactly in the x-y plane (z=0), but fails if you move the slice up or down.