How to calculate volume change of specific ROIs between two point clouds?
Show older comments
I need to calculate the volume change between two point clouds representing consecutive timesteps of an experiment. The workflow I have come up with is as follows:
- import point clouds and decorrelation map
- generate mesh of pcs
- subtract pc1 from pc2 to generate z-change
- create mask to isolate regions of correlation map where value < 0.7
- apply mask to z-change to pick out ROIs
- use area of ROI and z-change to calculate volume of each decorrelated region
So far I've managed steps 1 through 3, and have attempted 4 using some code I have from a prior segmentation project, but I'm not managing to get any further. I have included the code I have here, attached the workspace with pc data, and the correlation map is inserted below the code. Eventually this needs to be put into a loop to process sets of ca. 1200 timesteps, but for now I'm just trying to get it to work for one.
% Generate mesh
x=linspace(min([Xpre;Xpost]),max([Xpre;Xpost]),1000);
y=linspace(min([Ypre;Ypost]),max([Ypre;Ypost]),1000);
[X,Y]=meshgrid(x,y);
Fpre=griddata(Xpre,Ypre,Zpre,X,Y);
Fpost=griddata(Xpost,Ypost,Zpost,X,Y);
% Point cloud subtraction and visualisation
figure()
colormap('jet')
mesh(X,Y,zeros(size(X)),Fpost-Fpre)
view([0 90])
colorbar
exportgraphics(figure,'t0775.png')
changeMap = imread('t0775.png');
% Read correlation map and generate mask
corrMap = imread('B0775.png');
mask = im2gray(corrMap);
BW = bwlabel(mask);
label_bg = BW(1,1);
uniquelabels = sort(unique(BW(:)));
% % This is where I get stuck and think I've gone wrong
nb_pixel_in_label = [];
for i1 = 1 : length(uniquelabels)
if uniquelabels(i1) ~= label_bg
nb_pixel_in_label(i1) = numel(find(BW==uniquelabels(i1)));
else
nb_pixel_in_label(i1) = 0;
end
end
idx_roi = find(max(nb_pixel_in_label) == nb_pixel_in_label);
new_mask = zeros(size(mask));
for i1 = 1 : length(uniquelabels)
if uniquelabels(i1) == uniquelabels(idx_roi)
new_mask(find(BW==uniquelabels(i1))) = 1;
else
new_mask(find(BW==uniquelabels(i1))) = 0;
end
end
zoneChange = changeMap .* repmat(new_mask,[1,1,3]);
Correlation map (img B0775.png)

Accepted Answer
More Answers (0)
Categories
Find more on Image Preview and Device Configuration 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!