Question

I am trying to make a binary region of interest mask over an image stack (GUI). Here is what I have thus far:

% Initalize lesion mask
LesionMask = zeros(size(handles.ImageOne));

% Create an ellipse for roi analysis

Lesion = imellipse(handles.axes1);

% Save roi to 3D binary mask
LesionMask(:,:,handles.CurrentSlice) = Lesion.createMask();

boundary = bwboundaries(LesionMask(:,:,handles.CurrentSlice))

Now I would like to overlay the boundary over my image, in particular, I would like it to stay even when I go through my image stack.

In short, I would like to plot the edge of the ellipse over my image.

Thanks!

Was it helpful?

Solution

This might work for you when added to your code at the end -

hold on
for k = 1:numel(boundary)
    plot(boundary{k}(:,2), boundary{k}(:,1), 'r', 'Linewidth', 3) %// Red border
end

Inspired from this blog

If you would like to keep the edge on the image saved for later usage, try this -

[M,N,C] = size(handles.ImageOne)
t1 = cell2mat(boundary);
ind1 = sub2ind([M N],t1(:,1),t1(:,2));
ind2 = bsxfun(@plus,ind1,[0:C-1].*(M*N));
handles.ImageOne(ind2)=0; %// Creates a black border
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top