Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

getting x and y for 3d

Asked by neenu jose on 15 Oct 2011

1.how can i obtain real world X and Y from x and y obtained from an image? 2.is scaling factor in x dirn*x=X and scaling factor in y dirn*y=Y ? if then how could i find the scaling factors?

1 Comment

neenu jose on 16 Oct 2011

i have a stereo image pair with me..which is not directly taken from camera..then how could i get answer for my qn.?

neenu jose

Products

No products are associated with this question.

4 Answers

Answer by Naz on 16 Oct 2011
Accepted answer

A=yourPicture;

[H L]=size(A);

dx=theRealLengthOfTheView/H; %this you must know, otherwise you can not scale the image.

dy=theRealWidthOfTheView/L;

figure(1);imagesc(A);

h=impoint;

[y x] = getPosition(h);

X=dx*x;

Y=dy*y;

Where your X and Y will be the real world distances from the origin (0,0) at the top left corner of the picture.

3 Comments

Naz on 16 Oct 2011

My bad. I missed the whole idea about 3D image

Walter Roberson on 17 Oct 2011

Neenu, this only works for 2D planes. Also, you will seldom directly have the "real length of the view" or the "real width of the view": you are more likely to have only the distance to the view and the camera aperture (which allows you to calculate the angle spanned by the image.)

HHWin on 12 Mar 2012

Hi Naz,

I have tried the code but it doesn't work.
I also have problem with converting Pixel to mm for X-Axis only.

Naz
Answer by Image Analyst on 15 Oct 2011

You need to put a known object (of known length) in the image, such as a yard stick or meter stick or something else that you know the actual real world dimension of.

2 Comments

Walter Roberson on 15 Oct 2011

Based upon earlier questions, I believe the question has to do with stereo image pairs and objects at different depths.

You still need a known object, but the perspective corrections complicate matters.

Image Analyst, did you reply to someone with a link to stereo work sometime around Wednesday?

Image Analyst on 16 Oct 2011

Could be. I think I remember this person asking 2 or 3 questions on essentially the same topic last week. If they want 3D modeling based on stereoscopic views, then that is a fairly common question and I gave an interesting link 11 days ago in the newsgroup: http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/3f817cb022050ab2/9b4f0176bc79e543?hl=en&lnk=gst&q=autocad#9b4f0176bc79e543 I'll just repeat it here:

Here's a way to make your own 3D models with your own digital camera.
Snap photos of a product, a room, a person, etc. with your own camera
and turn into a 3D model that people can manipulate on their computer
or mobile phone.

Autodesk Labs Utilities Project Photofly 2.0
http://labs.autodesk.com/utilities/photo_scene_editor/

Allows anyone with a digital camera to create near accurate 3D models
from photographs using the web. Utilizes common point and shoot
digital cameras. Harnesses the power of cloud computing to translate
photos into detailed 3D models. 3D models can be manipulated by design
software (e.g., AutoCAD, Inventor, 123D).

If you want a more professional system, see
http://www.3dmd.com/
http://www.canfieldsci.com/imaging_systems/…

Image Analyst
Answer by Walter Roberson on 16 Oct 2011

Neenu, if you already have the stereo image pair and cannot go back and retake the images with an object of known size in the images, then you cannot reliably determine the "real world" scaling factors of the images.

When you are watching Star Wars, and the enormous Imperial Battle Cruiser flies across the screen, how big is that Battle Cruiser in the "real world" ? The real answer is "about half of a metre": they used a detailed model and filmed from very close up to give the impression of a very very big object. You could watch the IMAX 3D version of Star Wars and it would still be the case that the Battle Cruiser was really only about 0.5m long: false perspectives in 3D are still false perspectives.

2 Comments

neenu jose on 18 Oct 2011

can i obtain parameters using camera caliberation toolbox?

Walter Roberson on 18 Oct 2011

I do not know; I am not familiar with that toolbox.

Walter Roberson
Answer by Image Analyst on 21 Oct 2011

You could also look at Chapter 11 in Richard Szeliski's book http://szeliski.org/Book/drafts/SzeliskiBook_20100903_draft.pdf

6 Comments

Walter Roberson on 20 Dec 2011

http://en.wikipedia.org/wiki/Exchangeable_image_file_format

It would not apply in your situation of using getsnapshot

On focal length:

http://www.physicsforums.com/showthread.php?t=209980

http://forums.logitech.com/t5/Webcams/Ask-about-focal-length-of-webcam-C905/td-p/509454

http://opencv-users.1802565.n2.nabble.com/How-t-o-measure-focal-length-in-logitech-webcam-td5316245.html

If you go through that information and think about it, you will see that you need some real-world information -- either real-world distance to an object or real-world size of an object (size in the plane perpendicular to the sensor). If you do not have either of those, you cannot calculate the focal length.

Also, if the webcam has adjustable focus, then that affects the distance between the lens and the focal plane (the sensor), which affects the calculation, so you would need to know that distance.

I have seen it written somewhere or other that as a rough guide, the focal length for fixed-lens webcams should be considered infinite for any object beyond 1 1/2 meters or so.

Image Analyst on 20 Dec 2011

"the focal length for fixed-lens webcams should be considered infinite for any object beyond 1 1/2 meters or so." - I think you mean "depth of field" rather than focal length. The longer the focal length the more zoomed in you are (smaller field of view), so an infinite focal length would have you looking at a scene the size of an atom! If it had a fixed focal length and focus then anything from 1.5 m to infinity would be roughly "in focus."

Walter Roberson on 20 Dec 2011

Thanks, that is probably what I meant. Though the logitech support person did use focal length the same way I did, so at least I'm not alone in my errors ;-)

Image Analyst

Contact us