joedf / ImgBeamer

SEM image formation process demo tool
https://joedf.github.io/ImgBeamer
MIT License
2 stars 0 forks source link

Spot sizing improvements #9

Closed joedf closed 1 year ago

joedf commented 1 year ago
joedf commented 1 year ago

Spot size calculation

// spc = spot-profile Circle/Ellipse
// scl = spot-content Ellipse
// sci = spot-content Image

// either spc or scl can be used, since the ellipse
// in spot-content is cloned and mirrors Spot profile

var cellWidth = sci.width() / Utils.getColsInput();
var cellHeight = sci.height() / Utils.getRowsInput();

var spotWidth = (spc.width() * spc.scaleX()) / (sci.scaleX() * cellWidth);
var spotHeight = (spc.height() * spc.scaleY()) / (sci.scaleY() * cellHeight);

Correction - depends on spot shape/eccentricity

var scaleEcc = Math.max(spc.scaleX(), spc.scaleY());
var spotWidthOrHeight = (spc.width() * spc.scaleX()) / (sci.scaleX() * sci.width() / Utils.getColsInput()) / scaleEcc;

Reliable formula is available already in Utils.updateDisplayBeamParams() ... Important comment on "maxScale" or Math.max(beam.scaleX(), beam.scaleY()) here:

screenshot

resulting formula can be

var spotWidth = (spc.width() / sci.scaleX()) / (sci.width() / Utils.getColsInput()) * spc.scaleX() / Math.max(spc.scaleX(), spc.scaleY())

helpful selectors

spc = stages[2].getLayers()[0].getChildren()[0]
sci = stages[3].getLayers()[0].getChildren()[1]

Spot size to spot-content image scale calculation

var spotWidth = 0.1550688; // 15.50688 %
var cellWidth = sci.width() / Utils.getColsInput();
// sci.scaleX()
var scaleX_to_use_for_sci = ((scl.width() * scl.scaleX()) / spotWidth) / cellWidth;

Eccentricity/Shape-correct solution

G_SETW = function(wp=100){
    /* eslint-disable */
    var beam = compositeBeam;
    var userImage = userScaledImage;

    // calculate the new scale for spot-content image, based on the given spot width
    var cellSize = Utils.computeCellSize(userImage, Utils.getRowsInput(), Utils.getColsInput());
    var maxScale = Math.max(beam.scaleX(), beam.scaleY());
    var eccScaled = beam.scaleX() / maxScale;
    var newScale = ((beam.width() * eccScaled) / (wp/100)) / cellSize.w;

    // userImage.scale({x: newScale, y: newScale});
    Utils.centeredScale(userImage, newScale);

    // propagate changes and update stages
    updateBeams();
    doUpdate();
    /* eslint-enable */
};
joedf commented 1 year ago

Adding prompt for spot width %

Screenshots