I have 2D data structed by 64X100000 size. 64(rows) represent "phase (-31:1:32)" and 100000 (column) represent "voltage" about the range of (-0.4 ~ 0.4).
I want to watch a probabilty based histogram (pdf) of this data in 64 time instances.
enter image description here<----- Like this pic.
How can I make a 3D plot that shows the changes of voltage histogram through 64 phases?
Related
I have 64 sensors distributed in a 8x8 square. They record data during a time t at a certain frequency, so for each sensor I have N values.
I would like to be able to observe those data, with a 2D representation of all the values at a certain time. With the X and Y axis being the coordinate of the sensor in the square, and the value displayed as the intensity.
So far I've only be able to stock all the data in a matrix : Map(8x8xN). So I can access my square of data at a time t by doing : Map(:,:,t).
But now I'm kinda stuck since a while on how to do a 2D representation of this Map(:,:,t) ? I can see it in the "Variables" windows of Matlab but can't display it in a 2D colorfull map ^^"
I tried my best with the contourf function but can't understand how it works.
Thanks
Try something like this:
v=zeros(9,9);
v(1:8,1:8)=Map(:,:,2);
pcolor(v);
I have pictures in .dcm format. From Dicominfo I learned that the pixel spacing is [0.9,0.9] mm and the slice thickness is 1.98 mm.
My task: I should get the picture size in real (world) coordinates and then display the pictures in all three projections in matlab.
I had an idea that I would create a matrix in matlab, but it is difficult for me to create the pixel size spacing.
I mean that the pixel in the matrix is like a square and is 0.9mm * 0.9mm.
I don't know if my approach is correct and if there is an easy way to solve the problem.
Thank you very much for every answer
several plotting functions allow you to specify x/y/z positions of each pixel/voxel, including imagesc, pcolor, here is an example using imagesc.
% vol stores your dicom volume
vol=rand(40,50,30);
dx=[0.9,0.9,1.98];
imagesc((0:size(vol,1)-1)*dx(1), (0:size(vol,2)-1)*dx(2), vol(:,:,1))
I am trying to get a slice of an elongated object in a 3d matrix (227x297x187 binary) that is orthogonal to its orientation..i.e. output image would be a 2d cross-section.
I was thinking the best way to do this would be to find a vector giving the orientation at some point on the object (so for a cross-section at the 40th slice I get the location of centroids at the 30th and 50th slices and find the vector between them), then get a list of pixels corresponding to a plane orthogonal to that vector at the desired slice (along centroid of object at 40th slice), and then retrieve the values in the matrix corresponding to those locations. Assuming the code I have attached finds the plane, I can plot it with surf() but don't know how to translate that into pixel locations in the matrix to generate the values for the 2d cross-section.
startslice=30;
endslice=50;
startnums=bwconncomp(binMATRIX(:,:,startslice));
startnums=regionprops(startnums,'Centroid');
endnums=bwconncomp(binMATRIX(:,:,endslice));
endnums=regionprops(endnums2,'Centroid');
midnums3=bwconncomp(binMATRIX(:,:,(startslice+(endslice-startslice)/2)));
midnums3=regionprops(midnums,'Centroid');
startstuff=[startslice, startnums.Centroid];
endstuff=[endslice, endnums.Centroid];
midstuff=[(startslice+(endslice-startslice)/2), midnums.Centroid];
nullstuff=null(endstuff-startstuff);
A=nullstuff(:,1);
B=nullstuff(:,2);
[x,y]=meshgrid(A,B);
z=1-x-y;
surf(x+midstuff(1),y+midstuff(2),z+midstuff(3))
I have a 3D data matrix which contains information about a scene (which voxels are free / occupied and belong to which class).
So far to plot the data I have to plot 2D slices using imagesc.
I'd like to plot the data as a pointcloud using Matlabs pcshow which should only display occupied voxels and the display the rest as empty space.
How can I convert my 3D matrix into a pointcloud object?
For some NxMxK matrix A where A == 255 indicates free voxels:
% make coordinate grid the size of A
[X,Y,Z] = meshgrid(1:size(A,1),1:size(A,2),1:size(A,3));
% move to xyz format
xyz=[X(:) Y(:) Z(:)];
% show points which are not free and where group values are used as color (scaled by to current colormap)
pcshow(xyz(A~=255,:),A(A~=255))
I have two images(both are exactly same images) and I am trying to calculate the disparity between them using sum of squared distances and reconstruct disparity in 3D space.
Do I need to rectify the image before calculating disparity?
The following are the steps that I have done so far for disparity map computation(I have tried with rectification and without rectification but both are returning all zeroes disparity matrix).
For each pixel in the left image X,
Take the pixels in the same row in the right image.
Separate the row in right image to windows.
For each window,
Calculate the disparity for each pixel in that window with X
Select the pixel in the window which gives minimum SSD with X
Find the pixel with minimum disparity among all windows as the best match to X
Am I doing it correctly?
How can I visualise the 3D reconstruction of the disparity as scatter plot in matlab?
Rectification guarantees that matches are to be found in the same row (for horizontally separated cameras). If you have doubts about rectification of your images you can try to compare rows by drawing horizontal lines between horizontally separated images. If the lines hit the same features you are fine, see the picture below where images are NOT rectified. The fact that they are distorted means there was a lens distortion correction as well as attempted (but not actually performed correctly) rectification.
Now, let’s see what you meant by the same images. Did you mean the images of the same object that were taken from different viewpoints? Note that if the images are literally the same (the same viewpoints) the disparity will be zero as was noted in another answer. The definition of disparity (for horizontally separated cameras) is a value of shift (in the same row) between matching features. The disparity is related to depth (if optical axes of cameras are parallel) as disparity d=f*B/z, where z - depth, B - baseline or separation between cameras and f is a focal length. You can transform the formula above into disparity/B=f/z which basically says that disparity related to camera separation as focal length is related to distance. In other words, the ratios of horizontal and distance measures are equal.
If your images are taken with the cameras shifted horizontally the disparity (in a simple correlation algorithm) is typically calculated in 5-embedded loops:
loop over image1 y
loop over image1 x
loop over disparity d
loop over correlation window y
loop over correlation window x
Disparity, or D_best, gives you the best matching window between image1 and image2 across all possible values of d. Finally, scatterplots are for 3D point clouds while disparity can be rather visualized as a heat color map. If you need to visualize 3D reconstruction or simply saying a 3D point cloud calculate X, Y, Z as:
Z=fB/D, X=uZ/f, Y=v*Z/f, where u and v are related to column and row of wxh image as
u=col-w/2 and v=h/2-row, that is u, v form an image centered coordinate system.
If your two images are exactly the same, then the disparity would be 0 for every pixel. You either have to use two separate cameras to take the images, or take them with a single camera from two different locations. The best way to do 3D reconstruction is to use a calibrated stereo pair of cameras. Here is an example of how to do that using the Computer Vision System Toolbox for MATLAB.