annotate inst/roicolor.m @ 892:a2140b980079

iptcheckconn: implement in C++ as static method for connectivity. * iptcheckconn.m: file removed; help text and tests reused for C++. * conndef.cc: implement two new connectivity::validate() methods and the iptcheckconn function for Octave as caller to those methods. * conndef.h: define the connectivity::validate() static methods. * COPYING
author Carnë Draug <carandraug@octave.org>
date Wed, 01 Oct 2014 20:22:37 +0100
parents 1d04ebf01532
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
560
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
1 ## Copyright (C) 2004 Josep Mones i Teixidor <jmones@puntbarra.com>
186
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
2 ##
560
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
3 ## This program is free software; you can redistribute it and/or modify it under
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
4 ## the terms of the GNU General Public License as published by the Free Software
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
5 ## Foundation; either version 3 of the License, or (at your option) any later
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
6 ## version.
186
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
7 ##
560
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
11 ## details.
186
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
12 ##
560
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
13 ## You should have received a copy of the GNU General Public License along with
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
186
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
15
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
16 ## -*- texinfo -*-
560
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
17 ## @deftypefn {Function File} {@var{BW} =} roicolor (@var{A}, @var{low}, @var{high})
186
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
18 ## @deftypefnx {Function File} {@var{BW} = } roicolor (@var{A},@var{v})
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
19 ## Select a Region Of Interest of an image based on color.
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
20 ##
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
21 ## BW = roicolor(A,low,high) selects a region of interest (ROI) of an
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
22 ## image @var{A} returning a black and white image in a logical array (1 for
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
23 ## pixels inside ROI and 0 outside ROI), which is formed by all pixels
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
24 ## whose values lie within the colormap range specified by [@var{low}
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
25 ## @var{high}].
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
26 ##
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
27 ## BW = roicolor(A,v) selects a region of interest (ROI) formed by all
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
28 ## pixels that match values in @var{v}.
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
29 ## @end deftypefn
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
30
560
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
31 function BW = roicolor (A, p1, p2)
186
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
32 if (nargin < 2 || nargin > 3)
560
1d04ebf01532 image: replace calls to usage() by print_usage() (usage is redundant and going to be deprecated in 3.8). Also small improvements on texinfo and use of defaulr arguments for simpler input check.
carandraug
parents: 274
diff changeset
33 print_usage;
186
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
34 endif
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
35
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
36 if (nargin == 2)
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
37 if (!isvector(p1))
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
38 error("BW = roicolor(A, v): v should be a vector.");
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
39 endif
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
40 BW=logical(zeros(size(A)));
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
41 for c=p1
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
42 BW|=(A==c);
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
43 endfor
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
44 elseif (nargin==3)
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
45 if (!isscalar(p1) || !isscalar(p2))
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
46 error("BW = roicolor(A, low, high): low and high must be scalars.");
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
47 endif
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
48 BW=logical((A>=p1)&(A<=p2));
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
49 endif
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
50 endfunction
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
51
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
52 %!demo
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
53 %! roicolor([1:10],2,4);
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
54 %! % Returns '1' where input values are between 2 and 4 (both included).
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
55
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
56 %!assert(roicolor([1:10],2,4),logical([0,1,1,1,zeros(1,6)]));
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
57 %!assert(roicolor([1,2;3,4],3,3),logical([0,0;1,0]));
13c6a9bdec24 Changed the structure to match the package system
hauberg
parents:
diff changeset
58 %!assert(roicolor([1,2;3,4],[1,4]),logical([1,0;0,1]));