On-line drawing scaler

Includes workshop practice, painting and weathering, model photography etc.
User avatar
Guy Rixon
Posts: 799
Joined: Sun Mar 27, 2011 6:40 pm

On-line drawing scaler

Postby Guy Rixon » Mon Dec 28, 2020 11:14 pm

Given a drawing and one known dimension, it's simple to extract other, unmarked lengths by scaling. One just has to do the arithmetic without errors such as multiplying by the scale factor when one should divide. Given a scan of a drawing, one also needs something to pick off the lengths in pixels.

I've written a drawing-scaler web-application that allows one to extract the pixel lengths with the mouse and which does the sums the right way up. It's at an early stage and has a few limitations, such as not coping with browser zooming. I may refine it over time.

"Web application" here just means a web page with a bit of Javascript included. Nothing is uploaded to or saved on the web server and all the calculations are done in the browser. You can save the page source and run it off-line if you like: just open the local file in your browser.

Stephan.wintner
Posts: 28
Joined: Sun Mar 15, 2020 11:04 pm

Re: On-line drawing scaler

Postby Stephan.wintner » Tue Dec 29, 2020 6:25 am

That's fantastic Guy. I wish I'd had that for some drawings I did a while ago.

I think it'd be quite complex, but if you can see a way to handle a photo that is skewed, rather than square to the subject, that'd be a very useful enhancement.

Thanks!
Stephan

User avatar
Guy Rixon
Posts: 799
Joined: Sun Mar 27, 2011 6:40 pm

Re: On-line drawing scaler

Postby Guy Rixon » Tue Dec 29, 2020 9:44 am

Deprojecting a photo is quite involved, in the cases that matter for railway photos, because the effects of the subject being at an angle are mixed up with how the light from the subject is projected onto the focal plane of the camera.

I could write something that handles the tangent-plane projection for a perfect camera infinitely far from the subject (it's a standard process in astronomy), but photos from a real-world camera at a finite distance need different treatments.

I suspect that the necessary software is already around. I'll have a look.

User avatar
grovenor-2685
Forum Team
Posts: 3448
Joined: Sun Jun 29, 2008 8:02 pm

Re: On-line drawing scaler

Postby grovenor-2685 » Tue Dec 29, 2020 10:29 am

Sorting out skewed images can be done in The Gimp, Martin Wynne has tutorials on his Templot site.
Regards
Keith
Grovenor Sidings

User avatar
Will L
Posts: 1968
Joined: Sun Jul 20, 2008 3:54 pm

Re: On-line drawing scaler

Postby Will L » Tue Dec 29, 2020 11:46 am

Guy Rixon wrote:I've written a drawing-scaler web-application that allows one to extract the pixel lengths with the mouse and which does the sums the right way up.

Absolutely Magic Guy, this is going to be really useful. Thank you, its already bookmarked. A cookie that remembered my previously used drawing images and setting would be nice. What file format does it handle, I already know it works on .jpg but not on .psd and it wont accept .pdf.

Clearly the trick is to set the original dimension on something big, like the wheel spacing (on my J56 drawing this was 7ft), then defining it in scale millimetres (28). You can then read off what the the dimension should be on the model. I have just confirmed (fortunately) that the lamp irons should be just 2mm high.

For those who want to scale off photographs and already have a copy of Photoshop, you can use that to adjust the perspective of a picture to give you an reasonably correct flat side on view, There are limitations to what can be achieved thou.

User avatar
Guy Rixon
Posts: 799
Joined: Sun Mar 27, 2011 6:40 pm

Re: On-line drawing scaler

Postby Guy Rixon » Tue Dec 29, 2020 11:49 am

I found an article on correcting perspective in photography. It lists various packages that attempt this, mainly in respect of photos of buildings.

I had a try with Hugin, since it costs no money, but I find it to be broken on recent versions of MacOS. It seems to be trying to do the right kind of things, though.

The documentation for the GIMP says that its "perspective" function doesn't really correct perspective, but is just a shear distortion. Maybe that's enough sometimes.

In using any of these programs, we should be careful of the accuracy. We want (typically) photos trued up so that we can extract dimensions. The authors of the software packages just want to make prettier pictures. It's very easy to have an image that looks true to the eye but is still significantly distorted. The typical case of this is where the picture is corrected such that the verticals and horizontal lines are straight and perpendicular, but the scale varies with distance from the centre of the image.

User avatar
Guy Rixon
Posts: 799
Joined: Sun Mar 27, 2011 6:40 pm

Re: On-line drawing scaler

Postby Guy Rixon » Tue Dec 29, 2020 12:05 pm

Will L wrote:What file format does it handle, I already know it works on .jpg but not on .psd and it wont accept .pdf.

It's the intersection of what the file-selector thinks of as an image (everything that matches the MIME type "image/*") and what the browser can read. Therefore, at least JPEG, GIF, PNG, TIFF in essentially all browsers. Possibly a few other formats in some browsers. SVG is a possibility. CAD formats probably won't work.

Since the file-selecting and image-reading logic is in the browser, I can't readily extend it to other formats, useful though that might be.

A PDF "image" is actually a miniature one-page document wrapping a real image in another format. The inside image can sometimes be extracted and used separately. On a Mac, the preview application does a good job of conventing between formats, including PDF to proper graphics.

bevis
Posts: 48
Joined: Thu Jul 31, 2008 6:58 pm

Re: On-line drawing scaler

Postby bevis » Tue Dec 29, 2020 12:29 pm

Thanks for this Guy.
Already put it to use and fond it easy to manage.
Bevis

User avatar
Will L
Posts: 1968
Joined: Sun Jul 20, 2008 3:54 pm

Re: On-line drawing scaler

Postby Will L » Tue Dec 29, 2020 2:28 pm

Guy Rixon wrote:
Will L wrote:What file format does it handle, I already know it works on .jpg but not on .psd and it wont accept .pdf.

It's the intersection of what the file-selector thinks of as an image (everything that matches the MIME type "image/*") and what the browser can read. Therefore, at least JPEG, GIF, PNG, TIFF in essentially all browsers. Possibly a few other formats in some browsers. SVG is a possibility. CAD formats probably won't work.

Since the file-selecting and image-reading logic is in the browser, I can't readily extend it to other formats, useful though that might be.

A PDF "image" is actually a miniature one-page document wrapping a real image in another format. The inside image can sometimes be extracted and used separately. On a Mac, the preview application does a good job of conventing between formats, including PDF to proper graphics.


Thanks again Guy, that's pretty much what I expected, but i wanted to check given my IT background knowledge sort of fades towards nothing with image processing and what browsers are actually doing. But yes I was already up to extracting an drawing image from a PDF, dropping it into something like Photoshop and saving it back next to the PDF as a jpeg.

P.S. when I say Photoshop I mean a fairly old version of Photoshop Elements.

Stephan.wintner
Posts: 28
Joined: Sun Mar 15, 2020 11:04 pm

Re: On-line drawing scaler

Postby Stephan.wintner » Tue Dec 29, 2020 6:38 pm

Cheers Gents. I am aware, somewhat, of the principles involved in skewed images and un-skewing in Gimp.

When I've needed it I scaled the skewed image, rather than tried to unskew it - that's down to me being familiar with drawing perspective views on engineering drawings, and not familiar with how to actually unskew it. It worked out but is certainly a bit laborious and error prone. So I'll file those things away for future consideration, definitely helpful.

Stephan


Return to “Tools and Techniques”

Who is online

Users browsing this forum: No registered users and 1 guest