How to apply radial spatial filter on Matlab? - matlab

I have images that contain a series of concentric circles (artifacts), so I would like to apply some kind of radial spatial filter in order to smoothen these circles.
Any help on this would be really appreciated.
Regards,
Simon

You can:
Find the center of the image using center of mass calculations
Transform the image to polar coordinates (ImToPolar, need to download).
Filter in the radial direction (this would be a 1D filter in the x direction).
Transform back to cartesian coordinates.

Related

Calculating area on N points

Im trying to calculate numerically an area of different shapes where the only thing I know about them is the (x,y) of each corner.
For example the shapes are:
P.s. The points inside the shape are for other calculation, I only need the area of the most outer shape.
Thank you.
Create polygon, and use polyarea function.
Given x,y location of corners than:
Area=polyarea(x,y)

Volume reconstruction from 3D image gradient in Matlab

For 2D images- Gx and Gy gives the information on vertical and horizontal edge infromation respectively. Angle of the gradient direction vector can be calculated from inverse of tan(Gy/Gx) and edge direction will be perpendicular to the gradient direction vector.
I have 3D Z-stacked image datset so each pixel will be represented by (x,y,z) co-ordinate and with respective intensity value as well. I have used 3D image gradient link for initial reference.
(1) What if I want to derive whole volume/wireframe model just with the information of 3D image gradient magnitude and direction?
(2) Do I need X, Y and Z-stacked image data seperately in order to generate whole volume/wireframe model out of it?
In matlab, I can also develop whole volume just with 2D z-stacked masks using isosurface command. Here I am exploring other possibilities to generate wireframe volume/3D model.
Thanking you in anticipation.

I need to fit a best circle to the 3D data in matlab

Basically, I have a many irregular circle on the ground in the form of x,y,z coordinates (of 200*3 matrix). but I want to fix a best circle in to the data of x,y,z coordinates (of 200*3 matrix).
Any help will be greatly appreciated.
I would try using the RANSAC algorithm which finds the parameters of your model (in your case a circle) given noisy data. The algorithm is quite easy to understand and robust against outliers.
The wikipedia article has a Matlab example for fitting a line but it shouldn't be too hard to adapt it to fit a circle.
These slides give a good introduction to the RANSAC algorithm (starting from page 42). They even show examples for fitting a circle.
Though this answer is late, I hope this helps others
To fit a circle to 3d points
Find the centroid of the 3d points (nx3 matrix)
Subtract the centroid from the 3D points.
Using RANSAC, fit a plane to the 3D points. You can refer here for the function to fit plane using RANSAC
Apply SVD to the 3d points (nx3 matrix) and get the v matrix
Generate the axes along the RANSAC plane using the axes from SVD. For example, if the plane norm is along the z-direction, then cross product between the 1st column of v matrix and the plane norm will generate the vector along the y-direction, then the cross product between the generated y-vector and plane norm will generate a vector along the x-direction. Using the generated vectors, form a Rotation matrix [x_vector y_vector z_vector]
Multiply the Rotation matrix with the centroid subtracted 3d points so that the points will be parallel to the XY plane.
Project the points to XY plane by simply removing the Z-axes from the 3d points
fit a circle using Least squares circle fit
Rotate the center of the circle using the inverse of the rotation matrix obtained from step 5
Translate back the center to the original location using the centroid
The circle in 3D will have the center, the radius will be the same as the 2D circle we obtained from step 8, the circle plane will be the RANSAC plane we obtained from step 3

How to draw a sphere in matlab and patch it in a 3D plot?

I have a 3D plot and I want to put a sphere in a designed position. How can I create a sphere? I expected to use patch? Can anyone help me to do this please?
You can follow this:
Consider the center is at [c1,c2,c3]. The number of faces as r.
[x,y,z] = sphere(r);
surf(x+c1, y+c2, z+c3)
These two lines of code are enough to plot a sphere using the surf command.
For instance, if C=[2,2,2] and r=30 the result is as follows:
This is a sphere of radius 1 centered at [2,2,2]. To have a sphere with an arbitrary radius R, you should multiply the [x,y,z] values by R before adding the center.

Visualize 3D data in MATLAB

I have data on the form (x, y, z, v), in other words three spatial coordinates and one velocity magnitude. I would like to plot this in 3D, where the velocity magnitude is shown using color.
What is the best way to do this in MATLAB?
I assume you have trajectory data, so that your spatial coordinates represent the trajectory through space of one or more particles. In that case:
Have a look at quiver3 or coneplot.
If you want colored arrows, then have a look at quiver3d or quiverc (2D only) on the File Exchange.
If you only have 3 spatial coordinates and speed (= velocity magnitude), then your best bet is scatter3.
I could go on, but could you give me a bit more detail on what you want exactly?
Have you tried surf(x,y,z,v)?