Gray Matter Area and Volume Calculations
21 views (last 30 days)
Show older comments
Hello, I am working on gray matter area and volume calculation of brain MRI image. I have some doubts with my code below:
% Area Calculation
Pixel_Numbers = sum(J(:));
DistanceinUnit = 1.796875; %Based on pixel spacing (in mm?)
DistanceinPixel = sqrt(x^2+y^2);
DistancePerPixel = DistanceinUnit/DistanceinPixel;
Area = (Pixel_Numbers)*(DistancePerPixel^2); %Is it in mm^2 or mm^2/pixel?
% Volume Calculation (Is the formula correct?)
LengthinPixel = length(find(J(:)==1));
Length = LengthinPixel*DistanceinUnit;
Volume = Area*Length;
The information about pixel spacing is 1.796875\1.796875. I'd be glad if you can help me to figure out the answer. Here is the picture. Thank you.
Accepted Answer
Ryan Comeau
on 6 May 2020
Hello, i think you're image appears to be binarized already. This means we can obtain the area well with the regionprops function. https://www.mathworks.com/help/images/ref/regionprops.html.
In terms of the volume, are you wanting to sum up the number of pixel in that area * intensity? In you case if the image is binary, the volume and area will be the same. volume=area*height but height is 1 because your image is binary.
The last thing you want now is pixels to mm? just determine the conversion for this, if a pixel is 1.796875x1.796875 we will have an area=(1.796875)^2*num_pixels.
If all the area is one block, it will be returned from regionprops, if not you'll need to sum it up. Here is my logic for this problem:
image=imread('J.jpg');
image=rescale(image,0,1); %helps for binarization
BW_im=imbinarize(image); %see documentation, it is versatile
hh=regionprops(BW_im,{'Centroid','Area',}); %centroid for locations.
total_area=0;
total_volume=0;
height=1;%your image is binary, if it's not this will change pixel by pixel.
%see the regionprops function to sum up pixel values as well.
for i=1:length(hh)
total_area=total_area+hh(i).Area;
total_volume=total_volume+(hh(i).Area*height)
end
area_in_mm=(1.796875.^2)*total_area;
Hope this helps, if not, drop a comment.
RC
3 Comments
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!