How to extract rib cage for finding region of interest ?

1 view (last 30 days)
Hello, Im trying to find lung roi from raw CT image. I cannot detect rib cage with bwarefilt() to extract because it checks just 2d, so cannot combine that info with connectivity. So I felt regionprops3 will help me but im not sure how to use regionprops3 to extract it, Im open to any alternative ways to extract that rib cage.
-no lung tissue should be lost
error in line 36:
Subscripting into a table using one subscript (as in t(i)) or three or more subscripts (as in t(i,j,k)) is not supported. Always specify a row subscript and a variable subscript, as in t(rows,vars).
my code is
source_path_raw = 'C:\Users\rawimage';
V_raw = niftiread(source_path_raw);
%to initialize
x=size(V_raw,1);
y=size(V_raw,2);
z = size(V_raw,3);
BW = zeros(x,y,z);
slice_num = size(V_raw,3);
V_raw = imbinarize(V_raw);
for i=1:slice_num
one_slice = V_raw(:,:,i);
radius =4; % radius 4,decomposition 0 veri kaybetmemek için en optimali
decomposition = 0;
se = strel('disk',radius,decomposition);
BW(:,:,i) = imerode(one_slice, se);
end
BW = imfill(BW, 'holes');
V_BW = bwareaopen(BW,100);
volumeViewer(V_BW(:,:,:));
% Attached creenshot from here
conn=18;
n=3;
cc = bwconncomp(V_BW,conn);
if (cc.NumObjects == 0), error('%s: error - input array is empty', mfilename); end
% Getting more information about the connected-components
rp = regionprops3(cc, "Volume");
Cent = rp(1).Volume;
crow = round(Cent(2));
ccol = round(Cent(1));
cplane = round(Cent(3));
% Sorting by size, largest first
[~, ind] = sort([rp.Volume], 'descend');
% Keeping only the n largest connected-components
rp = rp(ind(crow, ccol, cplane));
% Setting relevant indices in the output array
Xout = false(size(V_BW));
n = min(n,length(rp));
for i=1:n,
Xout(rp(i).PixelIdxList) = true;
end
% Keeping only the statistics of the n largest connected-components
rp = rp(1:n);
volumeViewer(Xout(:,:,:))

Accepted Answer

Matt J
Matt J on 27 Apr 2021
Edited: Matt J on 27 Apr 2021
I cannot detect rib cage with bwarefilt() to extract because it checks just 2d
A 3D (and higher) version of bwareafilt is available here
  23 Comments
Matt J
Matt J on 4 May 2021
Edited: Matt J on 4 May 2021
I'm afraid I don't understand the task. You mean you are trying to count the number of branches in different airway paths?
In any case, it doesn't sound like a simple application of erosion. think it would be a good idea to start a new thread where you can more fully explain the new task and where the answers offered by people can focus on that.
Berkem Teksüz
Berkem Teksüz on 4 May 2021
Okay I will open a new question, We do not need to count anything. its for just a sign for developer to stop, its done. I just need an airway segmentation as complex as that blue one.Thats all.Thank you!

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!