Setting Scale of Image Plane?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Setting Scale of Image Plane?

Post by quick61 »

HI all. With questions coming up more often about importing an image to be used as a reference for generating CAD draftings and parts from images of plans and photos, I was thinking of doing at least a mini tutorial on the subject, while doing my own project. The first thing I have come up against is a good way to scale the image plane to match the FreeCAD environment. As seen in the screenshot below, I have a photo of one of my old home made knives that I would like to make a set of handles for to be 3D printed. I included reference for scale and as you can see, the Draft Grid with spacing of 10 mm is dwarfed by the size of the image.
Image_Grid.png
Image_Grid.png (260.28 KiB) Viewed 5695 times
Anyone have any good methods to scale down the image with some resemblance of accuracy?

Ideally I would imagine a tool in the Image Workbench that would allow the drawing of a line between two known points in the image, like a measured or defined distance, and define that line to the known length and the image and line would scale to that size.

Lacking that, any tricks or work arounds you all might have, please reply. I'v managed to scale the image to "real close" but it was more than a little fiddling about to get there. More of a trial/error/redo kind of operation.

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Setting Scale of Image Plane?

Post by shoogen »

I would use a raster image program (gimp) to correct for the perspective and meassure the distances in picture in pixels.
Rather then photograping a caliper, i would use ruled paper, probably with additional markings to ease counting. Or printouts of special ruler paterns like the "E"
Image
A feature to calibrate the scale in FreeCAD would sure, be helpful. But i think a skilled user should take the perspective deviations into consideration.
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Setting Scale of Image Plane?

Post by quick61 »

A feature to calibrate the scale in FreeCAD would sure, be helpful. But i think a skilled user should take the perspective deviations into consideration.
Giving my own project some more thought, tracing the outline on paper with marked scale would be a better way to go than with the photo of handle and caliper.
I would use a raster image program (gimp) to correct for the perspective and measure the distances in picture in pixels.
OK, I guess my question would then be, knowing how many pixels are within a mm or 10 mm, how would that then translate into scaling the image to be the correct size in the image plane? Maybe there is something obvious here that I'm missing, but this one has me scratching my head. :oops:

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Setting Scale of Image Plane?

Post by jmaustpc »

Just a quick thought...

If you had the original as you do in this case, you should us "david" 3d scanner and the points cloud stuff....Werner wrote a branch for this, its in sourceforge still but last time I tried did not compile and is now very out of date. I tried it at the time and it was pretty cool. You needed PCL. But as some of you will know I had PCL stop all my FreeCADs from compiling so I removed it until the issues are resolved. So I don't know how much of that points code functionality has made it into master.

At the very least you could import the points cloud and then use Draft snap to point to place and build shapes based on the points in the points cloud.


The point of using an image is for historic or reverse engineering, where only photos are available.
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Setting Scale of Image Plane?

Post by shoogen »

jmaustpc wrote:The point of using an image is for historic or reverse engineering, where only photos are available.
;)
Jim, this is fun if you are a university student, an have access to ridiculously expensive equipment. But using a kinnect or a webcam with structured light or laser lines won't get you far. Especially with a part that is only a few millimeters thick.
The part shown is nearly prismatic. If i had to choose i would use a http://en.wikipedia.org/wiki/Optical_comparator .

the david scanner is nice. But i wouldn't buy one, to get models of parts like this.
quick61 wrote:OK, I guess my question would then be, knowing how many pixels are within a mm or 10 mm, how would that then translate into scaling the image to be the correct size in the image plane? Maybe there is something obvious here that I'm missing, but this one has me scratching my head. :oops:
Say you measure 6 px/mm. Then you divide the dimensions of your image (say 1200 x 900px) by that value and get the dimensions you set for the ImagePlane.
In this example 1200px / 6 (px/mm) = 200mm as width or 900px / 6 (px/mm) = 150mm as height.

second example (with odd numbers):
image size: 551px x 314px
resolution: 2.665 px/mm (took the distance between the 0 and 100 on your caliper (266.5 px))
ImagePlane size: 206.54mm x 117.82mm
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Setting Scale of Image Plane?

Post by quick61 »

Thanks guys! I did some thinking on this last night and drifted back to my high school math. I think I came up with a workable solution, or at least one that will get me close enough. Not having a scanner, I snapped a pic of the outline I traced on a piece of 1 cm graph paper. I then imported the pic as an image plane and popped open Sketch Edit and drew a line between one of the 1 cm blocks and got the distance (256 mm). Then simply did the percentage difference 10/256 = 0.0390625 or 3.91%. I then opened the image in GIMP, and scaled the image to 3.91% and exported the reduced image and brought it into FreeCAD to be used.

This might be a simple and workable method for an image scaling tool in the Image Workbench. This would no doubt be more accurate with such things as scanned plans, blueprints, and the like. But most of the time, that seems to be what users are trying to do with the image imports anyway.

Now that I think I have this one solved, either with shoogen's method or my own, I'm back to lamenting the fact we can't yet Sweep along multiple paths. (issue #1587) ;)

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Setting Scale of Image Plane?

Post by yorik »

This discussion is interesting... Indeed for very small sizes like you guys usually work with, precision becomes a major problem. In the field of architecture, however, working from bitmap images and pictures is usually no problem... It is a common technique to reconstruct building models from photographs. The couple of centimeters of imprecision are totally acceptable on sizes of up to a hundred meters. In the old times before the laser devices, we used to measure existing buildings by hand in order to draw the plans, and we had about the same level -or worse- of imprecision.

And when you need to redraw old scanned building plans, the precision of the scanner is bigger than the precision of the guy who drew the plan by hand the first time...

That said, I'd be interested to also have a tool to easily scale an image in the image WB... Not too sure what/how that could be. I like the way you can do that in blender, you can for example draw a square of 10 units in size, then place your unscaled image (that contains an object of 10 units size) on top of it, move it to match one point of the image with a corner of the square, then, using that point as a base, rotate and scale the image.
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Setting Scale of Image Plane?

Post by quick61 »

Edit - yorik, would you like a feature request made out for this?

From back in my Sketchup days, (and the only reason I kept an old XP machine laying around on the KVM), you can simply draw a line between two known points, then type the known distance that line is to be and a dialog pops up and asks if you want to rescale the document or some such. In our case, when using such a tool, no need to ask about rescale as that is what one intends to do there. Maybe provide a script, that when invoked, would allow the user to draw a line (draft line with shift = ortho would do) and after the second mouse click, a dialog would ask the user to define the length of the line. The routine would then take the lines FreeCAD unit length and calculate the difference to the defined input and scale accordingly.

I'm sure it is much easier to say than program, but that is how I would envision such a tool to function.

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
r-frank
Veteran
Posts: 2180
Joined: Thu Jan 24, 2013 6:26 pm
Location: Möckmühl, Germany
Contact:

Re: Setting Scale of Image Plane?

Post by r-frank »

Hello.

I remember the first time i wanted to so such a thing my solution was to use an
on-screen ruler like this, measure out some distances on the image (in an image viewer),
calculating horizontal and vertical corection factor, resizing the picture in the viewer and then importing it in the CAD.

But it would be more convenient to do that work directly in the CAD.

AFAIK that is possible in LibreCAD ...

Roland
Deutsche FreeCAD Tutorials auf Youtube
My GrabCAD FreeCAD-Projects
FreeCAD lessons for beginners in english

Native german speaker - so apologies for my english, no offense intended :)
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: Setting Scale of Image Plane?

Post by mario52 »

hi
yorik wrote:That said, I'd be interested to also have a tool to easily scale an image in the image WB... Not too sure what/how that could be. I like the way you can do that in blender, you can for example draw a square of 10 units in size, then place your unscaled image (that contains an object of 10 units size) on top of it, move it to match one point of the image with a corner of the square, then, using that point as a base, rotate and scale the image.
this is exactly the principle of my macro 1 point = 1mm example old post

edit:add file exampleCut
Example_Cut.FCStd
Example : Bmp to FCStd
(59.41 KiB) Downloaded 87 times
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply