File: imedge3d.m

package info (click to toggle)
octave-iso2mesh 1.9.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 11,982; ansic: 10,158; sh: 365; makefile: 59
file content (37 lines) | stat: -rw-r--r-- 1,174 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
function imgdiff = imedge3d(binimg, isdiff)
%
% imgdiff=imedge3d(binimg,isdiff)
%
% Extract the boundary voxels from a binary image
%
% author: Aslak Grinsted <ag at glaciology.net>
% modified by Qianqian Fang <q.fang at neu.edu>
%
% input:
%   binimg: a 3D binary image
%   isdiff: if isdiff=1, output will be all voxels which
%         is different from its neighbors; if isdiff=0 or
%         ignored, output will be the edge voxels of the
%         non-zero regions in binimg
%
% output:
%   imgdiff: a 3D logical array with the same size as binimg
%            with 1 for voxels on the boundary and 0 otherwise
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

invol = 1;
if (nargin == 2)
    invol = isdiff;
end
binimg = logical(binimg);
imgdiff = xor(binimg, binimg(:, :, [1 1:end - 1]));
imgdiff = imgdiff | xor(binimg, binimg(:, :, [2:end end]));
imgdiff = imgdiff | xor(binimg, binimg(:, [1 1:end - 1], :));
imgdiff = imgdiff | xor(binimg, binimg(:, [2:end end], :));
imgdiff = imgdiff | xor(binimg, binimg([1 1:end - 1], :, :));
imgdiff = imgdiff | xor(binimg, binimg([2:end end], :, :));
if (invol)
    imgdiff = imgdiff & binimg;
end