Maintaining Square Pixels on Zooming Image


Does anyone have code that would maintain square pixels when zooming an image. I am working on a project where the the aspect ratio of a particle is an important feature. I do not want to have confusion by a zoom that sets the scales differently in X and Y.

I am looking to see if this problem has been solved before. Any code to share?

Hi Thomas,

It is my understanding that those features control the aspect ratio of the window when the window is resized by dragging an edge and I am more focused on the axis range within.

For example, the current image is 1024x1024 and I can constrain that to 1:1 aspect ratio. The issue arises in that the feature of interest is much smaller and the natural action is to use the marque tool and expand. However, if care and precision are not exercised then the marque window will not be square and the resulting expand will leave rectangular pixels that could lead to a false interpolation of the data if the user is unaware. Most picture based programs constrain the zoom to keep square pixels. The largest range of the marquee is used to set the range for both axis at least for a square image.

I would like to recreate this constraint for expanding. Ideally I would like the more general case where the pixels are square even for non-square images. I am envisioning some sort of window hook function and was interested if someone has already solved this problem.

If you set Width mode to Plan and set 1 * height * (top range/ left range), this does what you want, i.e. zooms and resizes the window to keep the pixels square. The problem is that if you select a tall and narrow or wide and short ROI the window can extend off screen, but otherwise... does this work for your needs?