Pixel Math Primer (make Crosshairs)

ngc1535

PixInsight Ambassador
A request to make crosshairs on an image recently came up on a forum.
I thought it would make a good way to introduce Pixel Math to those who might not have seen it before.
"Pixel Math is NOT scary" ... a series I am working on.

The expression is:

xc = trunc(width($T)/2);
yc = trunc(height($T)/2);
sz = 100;
iif(inrect(xc-sz/2,yc-sz/2,sz,sz) && (x() == xc || y() == yc),1,$T)

symbols of xc,yc and sz

xc and yc are the variables that are set to equal half the width and height of the image.
sz specifies the size of the crosshairs.

I did not both to clutter things up by specifying some fraction of the image in order to position anywhere. (The original request was for the "center.")

https://www.adamblockstudios.com/articles/pixel-math-crosshairs-parts-1-and-2

I like my expression. Of course... as I learned previously...someone smarter always knows an even more elegant solution. :)

-adam
 
Back
Top