PiranMOTO Layout From Image

LFI is a command-line windows app that processes a PNG image to detect points marked in specific 'pure' colours, and outputs an LFS layout file of those points. You can scale and offset the resulting layout, making it easy to create a perfectly scaled reference layout from an image of a real-world source.

The colours used are the 8 colours available when using only full or 0 values, ie, pure black, white, red, green, blue, yellow, cyan and magenta, and each produces a different object (3 colours of cones, 3 colours of posts, a tyre stack and a pillar). See reference image.

Full colour images such as screenshots of maps need to be cleaned of these colours before you can start marking them, this can be achieved with output levels. (If your software doesn't have that, photopea.com is a free online photoshop-like software that does: Go to Image > Adjustments > Levels, and move the output levels from 0 to 1, and 255 to 254.)

Once you've made your image, you need to calculate your scale. If you've used a screenshot of a map and left the scale markings in it, you can divide the stated width in metres divided the pixel width to get the ratio. The default is 0.0625, or 16 pixels per metre. Rounding errors mean this will be close, but it is recommended to fine-tune the ratio afterwards by comparing a known length that spans as much of the layout as possible. You can calculate the perfect ratio directly: new ratio = (old ratio / wrong distance) * correct distance.

The app is limited to 2400 control points, and will stop processing with an error if more are found (this usually means you've missed a patch of pure colour when preparing the image).

The layout is created in LA1X, named after the image, and is centred at 0,0 plus any offsets you specify.

Note: If you have any important, long, straight edges, it is recommended to rotate your source image so that this line is perfectly horizontal or vertical before you paint your control points.(LFS objects rotate in 1.6 degree steps, so you can't make perfectly straight lines at any angle. Rotating will anti-alias your control points - you can still see them, but as they're not pure colour any more, LFI will ignore them!)

Usage: lfi test.png <scale> <offset x> <offset y>

 - scale is metres-per-pixel, default 0.0625 (16px/m)
 - offsets are in metres, default 0
