Skip to content

Instantly share code, notes, and snippets.

@dbuscombe-usgs
Created July 26, 2013 02:00
Show Gist options
  • Save dbuscombe-usgs/6085464 to your computer and use it in GitHub Desktop.
Save dbuscombe-usgs/6085464 to your computer and use it in GitHub Desktop.
Black and white convex hull
function P = bwconvhull_alt(BW)
% usage: P is a binary image wherein the convex hull of objects are returned, BW is the input binary image
% P= bwconvhull_alt(BW);
warning off all
s=regionprops(logical(BW),'ConvexImage','BoundingBox');
P=zeros(size(BW));
for no=1:length(s)
P(s(no).BoundingBox(2):s(no).BoundingBox(2)+s(no).BoundingBox(4)-1,...
s(no).BoundingBox:s(no).BoundingBox(1)+s(no).BoundingBox(3)-1)=s(no).ConvexImage;
end
warning on all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment