Changeset 14580
- Timestamp:
- 04/15/13 14:23:24 (12 years ago)
- Location:
- issm/trunk-jpl/src/m/morphological
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/morphological/aggregation.m
r14525 r14580 1 function mask=aggregation(mask,windowsize,threshhold) 2 %congrid algorithm using windowsize pixel neighboors. 1 function [mask,varargout]=aggregation(mask,windowsize,threshhold,varargin) 2 %AGGREGATION - aggregation of an image to a lower sized image 3 % 4 % mask is an image of arbitrary size, format binary, with values 1 for foreground, and 0 for background 5 % mask is first convoluted with a square matrix of size windowsize (where windowsize is an even number), 6 % it is then filtered according to the threshhold value, and finally subsampled using 1/windowsize as 7 % sample scaling. 8 % x,y can be provided as optional arguments, as coordinates of the center points of the mask. aggregation will 9 % then return subsampled x,y arguments in output. 10 % 11 % Usage: mask2=aggregation(mask,7,7^2/2); 12 % [mask2,x2,y2]=aggregation(mask,7,7^2,x,y]; 13 % 14 % See also CLOSING, OPENING, DILATION, EROSION 3 15 4 %check on windowsize 16 %check input arguments %{{{ 17 %even windowsize 5 18 if mod(windowsize,2)==0, 6 19 error('windowsize should be an even number'); 7 20 end 8 21 9 %convolve: 22 %check on presence of varargin: 23 optional=0; 24 if nargin>3, 25 if nargin~=5, 26 help aggregation; 27 error('wrong number of optional arguments specified'); 28 else 29 optional=1; 30 x=varargin{1}; 31 y=varargin{2}; 32 end 33 end 34 35 %check on presence of varargout: 36 if optional, 37 if nargout~=3, 38 help aggregation; 39 error('wrong number of optional output arguments specified'); 40 end 41 end 42 %}}} 43 44 %convolve mask 10 45 matrix=ones(windowsize,windowsize); 46 mask=filter2(matrix,mask,'same'); 11 47 12 %convolve mask: 13 mask=filter2(matrix,double(mask),'same'); 14 48 %apply threshhold 15 49 pos=find(mask>threshhold); 16 50 pos2=find(mask<=threshhold); … … 18 52 mask(pos2)=0; 19 53 20 %now subsample: 54 %mask has been transformed into double format from the filter2 operation. Bring back to binary. 55 mask=logical(mask); 56 57 %subsample: 21 58 s=size(mask); 22 59 mask=mask(1:windowsize:s(1),1:windowsize:s(2)); 60 61 if optional, 62 s=size(mask); 63 varargout{1}=x(1:windowsize:s(2)); 64 varargout{2}=y(1:windowsize:s(1)); 65 end -
issm/trunk-jpl/src/m/morphological/vectorialize.m
r14536 r14580 1 1 function contours=vectorialize(mask,connectivity); 2 2 3 vec=bwboundaries(mask, 8);3 vec=bwboundaries(mask,connectivity); 4 4 5 5 contours=struct([]);
Note:
See TracChangeset
for help on using the changeset viewer.