-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] drop image proc toolbox dep. self-implement volgrow,shrink,clo…
…se,open
- Loading branch information
Showing
8 changed files
with
179 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function newvol = volclose(varargin) | ||
% | ||
% vol = volclose(vol, layer, mask) | ||
% | ||
% close a binary volume by applying layer-counter of growth operation | ||
% followed by layer-count of shrinkage operation | ||
% | ||
% author: Qianqian Fang, <q.fang at neu.edu> | ||
% | ||
% input: | ||
% vol: a volumetric binary image | ||
% layer: number of iterations for the thickenining | ||
% mask: (optional) a 3D neighborhood mask | ||
% | ||
% output: | ||
% vol: the volume image after closing | ||
% | ||
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) | ||
% | ||
|
||
if (isempty(varargin)) | ||
error('must provide a volume'); | ||
end | ||
|
||
newvol = volgrow(varargin{:}); | ||
newvol = volshrink(newvol, varargin{2:end}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function newvol = volgrow(vol, layer, mask) | ||
% | ||
% vol = volgrow(vol, layer, mask) | ||
% | ||
% thickening a binary image or volume by a given pixel width | ||
% this is similar to bwmorph(vol,'thicken',3) except | ||
% this does it in both 2d and 3d | ||
% | ||
% author: Qianqian Fang, <q.fang at neu.edu> | ||
% | ||
% input: | ||
% vol: a volumetric binary image | ||
% layer: number of iterations for the thickenining | ||
% mask: (optional) a 3D neighborhood mask | ||
% | ||
% output: | ||
% vol: the volume image after the thickening | ||
% | ||
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) | ||
% | ||
|
||
if (nargin < 2) | ||
layer = 1; | ||
end | ||
|
||
if (nargin < 3) | ||
if (ndims(vol) == 3) | ||
mask = zeros(3, 3, 3); | ||
mask(2, 2, :) = 1; | ||
mask(:, 2, 2) = 1; | ||
mask(2, :, 2) = 1; | ||
else | ||
mask = [0 1 0; 1 1 1; 0 1 0]; | ||
end | ||
end | ||
|
||
newvol = vol; | ||
|
||
for i = 1:layer | ||
newvol = (convn(newvol, mask, 'same') > 0); | ||
end | ||
|
||
newvol = double(newvol); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function newvol = volopen(varargin) | ||
% | ||
% vol = volopen(vol, layer, mask) | ||
% | ||
% open a binary volume by applying layer-counter of shrink operation | ||
% followed by layer-count of growth operation | ||
% | ||
% author: Qianqian Fang, <q.fang at neu.edu> | ||
% | ||
% input: | ||
% vol: a volumetric binary image | ||
% layer: number of iterations for the thickenining | ||
% mask: (optional) a 3D neighborhood mask | ||
% | ||
% output: | ||
% vol: the volume image after opening | ||
% | ||
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) | ||
% | ||
|
||
if (isempty(varargin)) | ||
error('must provide a volume'); | ||
end | ||
|
||
newvol = volshrink(varargin{:}); | ||
newvol = volgrow(newvol, varargin{2:end}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
function newvol = volshrink(vol, layer, mask) | ||
% | ||
% vol = volshrink(vol, layer, mask) | ||
% | ||
% thinning a binary image or volume by a given pixel width | ||
% this is similar to bwmorph(vol,'thin',3) except | ||
% this does it in both 2d and 3d | ||
% | ||
% author: Qianqian Fang, <q.fang at neu.edu> | ||
% | ||
% input: | ||
% vol: a volumetric binary image | ||
% layer: number of iterations for the thickenining | ||
% mask: (optional) a 3D neighborhood mask | ||
% | ||
% output: | ||
% vol: the volume image after the thinning operations | ||
% | ||
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) | ||
% | ||
|
||
if (nargin < 2) | ||
layer = 1; | ||
end | ||
|
||
if (nargin < 3) | ||
if (ndims(vol) == 3) | ||
mask = zeros(3, 3, 3); | ||
mask(2, 2, :) = 1; | ||
mask(:, 2, 2) = 1; | ||
mask(2, :, 2) = 1; | ||
else | ||
mask = [0 1 0; 1 1 1; 0 1 0]; | ||
end | ||
end | ||
|
||
totalmask = sum(mask(:)); | ||
newvol = vol; | ||
|
||
for i = 1:layer | ||
newvol = (convn(logical(newvol), logical(mask), 'same') == totalmask); | ||
end | ||
|
||
newvol = double(newvol); |