I've created a boundary around the lungs in this image & I would like to show just the area inside the boundar. How would I do this?
I've tried subracting it from the original image but had no luck. Any help would be greatly appreciated.
this is the code so far
I = imread('Image1.png'); %%Read in image
C = I(90:400,40:460); %%Crop out unnecessary parts
thresholded = C < 150; %%Threshold to isolate lung tissue
clearThresh = imclearborder(thresholded); %%Remove artifacts attached to border
BW = bwareaopen(clearThresh,100); %%Remove objects less than 40 pixels in size
dim = size(BW); %%Boundary trace one of the lungs
col = round(dim(2)/2)-130;row = find(BW(:,col), 1 );boundary = bwtraceboundary(BW,[row ,col],'N');imshow(C) %%Display Boundary on original image
hold on;plot(boundary(:,2),boundary(:,1),'r','LineWidth',3);BW_filled = imfill(BW,'holes'); %%Boundary Trace the second lung
boundaries = bwboundaries(BW_filled);for k = 1:2 b = boundaries{k}; plot(b(:,2),b(:,1),'g','LineWidth',3);end
Best Answer