I have been attempting to fill in a binary image in Matlab so that I am left with the entirety of this oval-like image like this.
However, I have been running into an issue in actually being able to define the red region. I have tried the following:
bwconvhull
function to fill the shape accurately, but then I do not know how to get rid of the inner shape to isolate just the red region.bwtraceboundary
function simply follows the entirety of the borders (on the inside and outside of the skull).Are there any similar functions to bwconvhull where I am able to expand a region from the center outward? My major difficulties have been in isolating either (a) the inner boundary of the skull or (b) the inner "black" region where the brain should be. My coding attempts can be found below:
Issue (a) - Tracing boundaries
hole=imread('Copy CT.jpg');
BW=im2bw(hole,.9);
dim=size(BW);
col=round(dim(2)/2);
row=min(find(BW(:,col)));
boundary = bwtraceboundary(BW,[row,col],'S');
x=boundary(:,2);
y=boundary(:,1);
Issue (b) - Isolating only the center
hole=imread('Copy CT.jpg');
BW=im2bw(hole,.9);
CH=bwconvhull(BW);
KH=CH-BW;
KH2=bwareaopen(KH,200);
Are there any particular functions that would be worth trying, or would there be another way to isolate the center of the circle so I can only highlight the red region? Any insight would be greatly appreciated!
I would approach this with these steps:
I am sorry I don't have actual code to back up this approach, but this will get you pretty close. You may need more steps to clean up the final result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With