3D spherical histogram

I have a collection of lines of unit length in space that have some orientation. From this I can calculate theta, phi using cart2sph.[THETA,PHI,R] = cart2sph(X,Y,Z) R would be unit, and of not much relevance here. Now I want a histogram matrix (N) using [theta phi]. In the end using N, theta, phi, I would like to plot a spherical histogram which is an extension of 2d polar command in matlab (which is polar(theta,rho)).
Regards Abhi...

댓글 수: 5

Walter Roberson
Walter Roberson 2011년 8월 8일
Could you point us to an example of a spherical histogram similar to what you would like to produce?
Image Analyst
Image Analyst 2011년 8월 8일
Yeah, I don't know what he means either. Why doesn't a simple 2D scatterplot of the theta histogram along one axis and the phi histogram along the other axis deliver the information you need for visualizing the distrubution?
Abhinendra
Abhinendra 2011년 8월 9일
Hi Walter,
even I am not sure how should it look like. being more specific,
like in 2D, once get histogram data(which is a vector) and the vector of theta bins.
Once can use polar(theta,rho) command to plot the distribution.
Similarly I have histogram data (matrix) of theta and phi bins (each of which is a vector).
Now I can convert (N,theta,phi) to (x,y,z) But now the problem is the normalization, as I get fewer points at poles and much more points at equator. So finally the problem comes at plotting the (intensity, theta, phi) data.
Bjorn Gustavsson
Bjorn Gustavsson 2011년 8월 9일
If you use bins with equal spacing in phi for all theta etc then the area of the solid angle for each bin in not constant, if so it should vary something like dA = sin(theta)*dtheta*dphi. Close to the pole that area decreases as sin theta. To get the pdf you have to normalize it.
Abhinendra
Abhinendra 2011년 8월 9일
Yeah Bjorn,
You are totally correct, in fact I am doing this.
The problem finally comes when I have to plot this data. Can you help me with final plotting of my data?
Abhi...

댓글을 달려면 로그인하십시오.

답변 (3개)

Honglei Chen
Honglei Chen 2011년 8월 8일

0 개 추천

Hi Abhinendra,
You can convert it to rectangular coordinate and then do the surface plot. You just need to make sure that you provide N as the color scale. Here is a quick example.
phi = linspace(0,2*pi,360);
theta = linspace(0,pi,180);
N = ones(180,360);
[P,T] = meshgrid(phi,theta);
surf(N.*sin(T).*cos(P),N.*sin(T).*sin(P),N.*cos(T),N)
HTH

댓글 수: 3

Abhinendra
Abhinendra 2011년 8월 9일
HI Honglei,
It is more or less what I am doing, but problem is with normalization of N. Number of data points at equator are much more than at poles.
I am not sure how to over come this problem of normalization.
THanks
Honglei Chen
Honglei Chen 2011년 8월 9일
Hi Abhinendra,
Assuming that your histogram is smooth, you could interpolate your result in a uniformly sampled (phi,theta) grid. This should help in your case.
HTH
Abhinendra
Abhinendra 2011년 8월 9일
Hi Honglei,
The histogram is set of discrete points. Where each element is the matrix represent the number of lines with orientation between theta(i) and theta(i+1) and between phi(j) and phi(j+1).
So finally I have N(which is discrete data points), theta and phi vectors and I have to plot a 3D polar histogram out of it.

댓글을 달려면 로그인하십시오.

Bjorn Gustavsson
Bjorn Gustavsson 2011년 8월 8일

0 개 추천

Well if you want a 3-D histogram (that is with bins in R, theta and phi) you should be well helped with these 3 FEX contributions:
They should work with 2-D histograms as well - as would a bunch of other FEX-submissions.
HTH

댓글 수: 1

Abhinendra
Abhinendra 2011년 8월 9일
Hi Bjorn,
I am almost following the similar lines.
but the final problem comes at plotting the data. If you can read my comment on my question and suggest something again, would be really nice.
Thanks

댓글을 달려면 로그인하십시오.

sree kasturi
sree kasturi 2011년 9월 12일

0 개 추천

Abhinendra,

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

질문:

2011년 8월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by