-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindNestArea.m
More file actions
27 lines (21 loc) · 832 Bytes
/
FindNestArea.m
File metadata and controls
27 lines (21 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [isNest, mask_next, bNum] = FindNestArea(ucmMat, mask_i)
%myFun - Description
%
% Syntax: output = myFun(input)
%
% Long description
sel = strel('disk',1);
mask_ring = imdilate(mask_i,sel);
mask_erode = imerode(mask_i, sel);
mask_ring(mask_erode == 1) = 0;
mask_fill = imfill(mask_i,'holes');
mask_fill_ring = imdilate(mask_fill,sel);
mask_fill_erode = imerode(mask_fill,sel);
mask_fill_ring(mask_fill_erode == 1) = 0;
idx_ard = unique(ucmMat(mask_ring==1)); % there may bath be element inner and suround
idx_fill_surd = unique(ucmMat(mask_fill_ring==1)); %only surround area
isNest = ~isequal(idx_ard, idx_fill_surd);
mask_next = mask_fill - mask_i;
% figure, imshow(mask_next,[]);
bNum = unique(ucmMat(mask_next==1));
end