Scaling the bitmap to pixel

18 views
Skip to first unread message

Payal Bhattacharjee

unread,
Jan 29, 2026, 1:10:44 AMJan 29
to mumax2
Hi everyone, 
I want to import a PNG bitmap derived from an SEM image containing nanostructures with no well-defined periodicity, and use it to define the geometry and dimensions of the nanostructures in the simulation. How should the bitmap be scaled to physical dimensions (nm) per pixel? Is the correct approach to assign a fixed real-space length to each pixel based on the SEM scale bar and then map this to the simulation cell size, as shown below?

geom2D := Imageshape("filename.png")
geom := geom2D.Scale(dx, dy, 1)
SetGeom(geom2D)
Save(geom)
where dx and dy are the cell sizes along the x and y directions. 

I really appreciate any help you can provide.

Josh Lauzier

unread,
Jan 29, 2026, 8:35:33 AMJan 29
to mumax2
Hi,

geom2D.Scale(dx, dy, 1) will rescale the image multiplicatively by that factor. so for instance, if dx=2 a feature that is 2 cells wide will be stretched to 4 cells wide. It does not use physical units of nm.

You will want to scale the image so that the physical dimensions in both the SEM image and the simulation match. For instance, if your SEM scale bar is 60nm and 10pixels long, and your cellsize in the simulation is 4 nm, the scale should be picked so that it is 15cells long. 

Cheers,
Josh L.
Reply all
Reply to author
Forward
0 new messages