Noeal asked:
I'm having an issue with the images, though:
taking a picture of a flat,
rectangular panel with a camera usually produces distortion (even with the
lens set to the narrowest angle possible).
Does anyone know of any freeware which will fix this? The image tool I
normally use (ImagePals, sort of a poor man's Photoshop) does have a 'warp'
function, but it requires setting up a grid of points, and is a pain to use:
optimal would be something where you mark the 4 corners, and few intermediate
edge points, and the image is automagically fixed.
You could do it "by eye" in Photoshop and GIMP-type tools, but I believe a far
better and more adjustable
way is to use an operation in imagemagick called affine transformation. With this you can
tweak the
result programmatically to the nearest pixel-to-millimetre value to get the best result.
For instance I have done an analogous task in which I removed perspective from black and
white images
of a WWII vehicle onto a flat elevation, so that accurate markings and camouflage patterns
or precise
positions of fittings can be obtained, by only knowing the basic perimeter edges.
To do this, I firstly need an accurate measurement of the side of the vehicle. Its exact
length, height
will do. This is easily obtained from scale modelling information. In your particular
case, I think only
the width and height of the panel would be needed, OR the two expressed as a ratio and
scaled later.
WORKED EXAMPLE:
Let's take for example an IBM System/360-40 console. It is comprised of a few
individual panels but they
are arranged in two larger rectangles, joined along one ege, but with an angle of about
163 degrees between
them. The upper panel's flat measurements are 711mm wide and 477mm long.
The lower panel is 71mm wide by 199mm high, as flat.
Say I then found any sufficiently detailed photo of a /40 console, and wanted to map the
surface of that
to my known panel edge measurements. The photo is of course taken from any arbitrary
angle.
I will use this one, 1200x953 pixels, presenting a common three-quarter side view, taken
fron the left:
https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/IBM_System_360_at…
The angled panels also show in the photo but that will be removed. Save the image
locally.
I tend to start at the pixel that is the top right corner. The image editor places the
origin at the top left corner.
Essentially the corners of the console rectangle in the photo - taking the upper panel
only, for this example -
need to be stretched to my known rectangle of TR=(711,0) to BR= (711,477) to BL=(0,477) to
TL=(0,0).
The rectangular polygon will automatically be closed back to the start. I'm using mm
but you could use any
measurement unit you like.
Next, load the above photo of the console in any good-enough image editor. I use the free
Paint.NET for this
purpose and I absolutely love it. Move around the photo, zoom in etc. and place the mouse
cursor exactly
on the top right corner and take a note of the pixel coordinate shown in the lower right
of the app. I make it
to be (675,141) on that particular photo.
Then do the same for the bottom right, bottom left, top left corner pixels. Remember this
is the top panel only,
the lower is done in the same fashion seperately. These are done in the same
point-to-point sequence as the
known measurements, and must be the same number of coordinates. It does not have to be a
rectangle, you
may have five, six or more coordinates for a say a vehicle or spaceship scale elevation.
So directly off the photo:
675,141 TR
646,315 BR
442,336 BL
458,129 TL
Now, assuming Imagemagick is installed, all we need to is tell it to stretch those
coordinates to our
known actual square coordinates by pairing them, pixel-to-known coordinate. On the command
line, or in
a text file enter and paste into the shell (I use git bash on Windows):
convert 1200px-IBM_System_360_at_USDA.jpg -virtual-pixel black -distort Perspective
"675,141 711,0 646,315 711,477 442,336 0,477 458,129 0,0"
Model40_upper_panel_transformed_true_flat1.jpg
Now the required de-perspective image will be in
Model40_upper_panel_transformed_true_flat.jpg
If you don't want to go through the above steps yourself you can see the result at
http://web.aanet.com.au/~malikoff/ibm/Model40_upper_panel_transformed_true_…
Then use the image editor rubber banding to select the required amount of this true
flattened image, now using
the original actual measurements as the pixel coordinates for cropping. eg. TR edge is
pixel (711,0) etc.
If the simple Perspective operation doesn't gove you a good result, try some other
Imagemagick operations eg:
convert 1200px-IBM_System_360_at_USDA.jpg -virtual-pixel black -interpolate Spline
-distort BilinearForward "675,141 711,0 646,315 711,477 442,336 0,477 458,129
0,0" Model40_upper_panel_transformed_true_flat2.jpg
this result #2 at
http://web.aanet.com.au/~malikoff/ibm/Model40_upper_panel_transformed_true_…
although I tend to find the Perspective does a better job. There is plenty of help on the
imagemagick.org site
and also Stack Overflow., such as
https://stackoverflow.com/questions/12276098/understanding-perspective-proj…
Further post-processing for me would be to then load this 711x477 image as the background
image layer in CAD
where it is fitted to a rectangle of the same size, in actual mm real world dimensions. I
can then overdraw all manner
of lines, construction lines, circles and other drawing elements to get a near-perfect
actual CAD drawing. Every so
often I just hide the background layer to see how it looks, and bits I've missed.
Sorry about the long blurb but hope it can help you on your panel.
Steve.