Reading 3D Xray CT image in Matlab and performing PCA

Hi, I have a Xray CT volume of few irregular shape. I want to read the file in Matlab and want to plot principal axis of each object using PCA. I've never worked in with 3D in matlab. Can anyone please suggest a procedure. Thanks.

 Accepted Answer

Segment your object. Then use find() to find the row, columns, and slice of the voxels. Then put them into columns and call pca(). Attached is a demo where I used PCA to find PCs of the 3-D color gamut. It will be easy for you to adapt it.

13 Comments

Sorry mate, Couldnot get it. I am attaching the data file saved from image (test(1)). The image will look like as below.
Please suggest.
Why do you think the PCA of that thing will be useful? Do you want to take one blob at a time and do PCA on that? That could possibly be useful.
Yes, I want one blob at a time get its principal direction. Then I need to draw 3D polarplot of all of them. Finally I will need to get the preferential direction of all the blobs. Please suggest.
Why not just call regionprops() and get the MajorAxisLength and Orientation?
Thanks Image analyst. But does it work in 3D? I need the mazor axis length for all the 3d objects.
Yes, regionprops is defined to work for arbitrary dimensions. A small number of the properties are only valid for 2D though.
Many thanks.
Basically I will need the vector representing the principal axis of each 3D region or object. Which property should I use?
By the way, just now I found Regionprops3 has been introduced in 2017b version. https://au.mathworks.com/help/images/ref/regionprops3.html?searchHighlight=regionprops3&s_tid=doc_srchtitle#outputarg_stats
Do you think that will make things easier to get the orientation of the 3d objects?
Probably - I haven't used it yet.
Make sure your 3-D blobs are all separated and not connected at all. If they're touching then you'll just have a huge blob instead of several smaller ones.
Yes you're right. I have separated those. Thanks for your excellent help. Happy holidays.
Hi Happy New Year.
Due to an issue with my computer I cannot enter my image files at the moment. I just want to know, if I read a 3D binary image file and convert the voxels with respect to global coordinates by simple arithmetic. But it is no more an image file. So, how can I use regionprops3 on it?
regionprops3() does not work on files, it works on matrix of data, which is what you would have.
regionprops works on arrays, and arrays are composed of elements with integer indexes. The array has no concept of spatially calibrated global coordinates, like whether the voxel spacing is 0.45 mm or whatever, all it knows is rows and columns, etc. If you have a spatial calibration to map indexes into real world coordinates, then you keep track of that separately. regionprops doesn't care (it ignores any spatial calibration you're thinking of) and works in voxels or pixels.
Excellent! Many thanks.

Sign in to comment.

More Answers (1)

Let me clarify my problem.
From xray CT, I have exported image of for example few 3D irregular shape particles as matfile (3200NnofilterXZ, attached). I have done PCA analysis of these particles in 2D to get the direction of the principal component of particles for each slice (2D). Screenshot of first few lines of my code is attached. But this will not be serving my purpose. I will need principal component of each particle in 3D and not 2D. Now, as I don't know how to deal with 3D image to get the pricipal component. I badly need to solve this urgently.
Please suggest.

1 Comment

Mathworks Consulting might possibly be open.
Most of the regular volunteers are on Christmas holidays and not willing to take on any "urgent" task. (To be more thorough: very few of the volunteers are willing to volunteer on "urgent" projects that take more than about 5 minutes to think about and write up, at the best of times, and even less so during this major holiday season.)

Sign in to comment.

Categories

Asked:

on 24 Dec 2017

Commented:

on 5 Jan 2018

Community Treasure Hunt

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

Start Hunting!