I have a 3D matrix in Matlab that was created using a volume MRI scan. I then use matlab toolbox iso2mesh (vol2surf) to convert this volume to a surface mesh and then extract the nodes/vertex coordinates and faces of this mesh.
However I find that this mesh is in the wrong coordinate system. I have tried to use the imrotate to rotate the matrix as well as rot90 to rotate the nodes matrix but it rotates the image only around the y-axis while I need rotation around both x and y axes.
Does anyone have any advice on what function I can use for this?
Thanks!
Related
I currently have two images of a plane in real life from straight above. One to use as a reference image, and another when the plane has undergone a rotation fixed at the centre of the plane thus changing its orientation. The camera stays at a constant position.
I was wondering if I found the homography matrix of this rotation in opencv and then decomposed the homography matrix in order to find the rotation matrix whether this would yield accurate results and I would be able to find the three angles needed to describe the planes rotation in euclidean coordinates to a reasonable degree of accuracy.
Thanks
I'm using VisualSfM to build the 3D reconstruction of a scene. Now I want to estimate the depthmap and reproject the image. Any idea on how to do it?
If you have the camera intrinsic matrix K, its position vector in the world C and an orientation matrix R that rotates from world space to camera space, you can iterate over all pixels x,y in your image and perform:
Then, find using ray tracing, the minimal t that causes the ray to intersect with your 3D model (assuming it's dense, otherwise interpolate it), so that P lies on your model. The t value you found is then the pixel value of the depth map (perhaps normalized to some range).
I have matrix A with size 5x3 which includes 3D (X,Y,Z) coordinates of some points and these points should be center of the spheres. and a vector B with size 5x1 which includes radius of each sphere. How can I plot the spheres around the points with defined radius in vector B and defined center in Matrix A?
Form Matlab docs
Description
The sphere function generates the x-, y-, and z-coordinates of a unit sphere for use with surf and mesh.
sphere generates a sphere consisting of 20-by-20 faces.
sphere(n) draws a surf plot of an n-by-n sphere in the current figure.
You'll need to scale those points by the radius of your sphere and translate them to the appropriate centre. Then plot them. 10 seconds of searching matlab documentation gave me the code to do that as well as to plot the spheres using the surf command.
surf
Create 3-D shaded surface plot
Here is the original image, the green colour is the background, and blue is the shape.
If my eye go closer to the shape, the blue square will be bigger like this:
If my eye go left, the shape will work like this:
I already know my eyes movement position, but how can I calculate what will the shape change? Any recommends? Thanks.
You need know the camera matrix http://en.wikipedia.org/wiki/Camera_matrix it will define the way which 3D coord will be projected to your sreen coordinates. If you know orientation of your camera, then you know 3d coords of object points relative to camera. Applying camera matrix transform to these 3d coords will give you 2d projections in you screen coordinates.
I'm trying to make a rubik cube game in webgl using three.js (you can try it here).
And I have problems to detect on witch axis I have to rotate my cube according the rotation of the cube. For instance, if the cube is in original position/rotation, if I want to rotate the left layer from down to up, I must make a rotation on the Y axis. But I rotate my cube 90 degrees on Y, I will have to rotate It on the Z axis to rotate my left layer from down to up.
I'm trying to find a way to get the correct rotation axis according the orientation of the cube.
For the moment I check witch vector of the axis of the rotation matrix of the cube is most parallel with the vector(0,1,0) if I want to move a front layer from down to up. But it do not works in edge cases like this for instance :
I guess there is some simple way to do that, but I'm not good enough in matrix and mathematical stuff :)
An AxisHelper can show the aixs of the scene which you could determine the orientation with.
var axishelper = new THREE.AxisHelper(40);
axishelper.position.y = 300;
scene.add(axishelper);
You could also log your cube and check the position and rotation properties with Chrome Developer Tools or Firebug.
You can store the orientation of each cube in its own 4x4 matrix (i.e. a "model" matrix) that tells you how to get from the cube's local coordinates to the world's coordinates. Now, since you want to rotate the cube around to an axis (i.e. vector) in world coordinates, you need to translate the axis into cube coordinates. This is exactly what the inverse of the model matrix yields.