comparison src/of-image-1-fixes.patch @ 4378:a3af3be14136

of-image: update image patch from image repo * src/of-image-1-fixes.patch: update patch
author John D
date Sun, 09 Apr 2017 16:38:37 -0400
parents 74c7af6a36c0
children
comparison
equal deleted inserted replaced
4377:54b1b8a285e6 4378:a3af3be14136
1 diff -uNr a/src/strel.cc b/src/strel.cc 1 diff -r c8bc315fa273 inst/bwperim.m
2 --- a/src/strel.cc 2016-10-21 10:19:56.258205086 -0400 2 --- a/inst/bwperim.m Sat Feb 11 23:54:52 2017 +0000
3 +++ b/src/strel.cc 2017-03-10 11:12:46.682214821 -0500 3 +++ b/inst/bwperim.m Sun Apr 09 09:03:52 2017 -0400
4 @@ -49,13 +49,13 @@ 4 @@ -20,7 +20,7 @@
5 ##
6 ## Values from the matrix @var{bw} are considered part of an object perimeter
7 ## if their value is non-zero and is connected to at least one zero-valued
8 -## element.
9 +## element, or to the outside of @var{bw}.
10 ##
11 ## Element connectivity @var{conn}, to define the size of objects, can be
12 ## specified with a numeric scalar (number of elements in the neighborhood):
13 @@ -71,7 +71,7 @@
14 for dim = 1:min (ndims (perim), ndims (conn))
15 conn_idx = tmp_conn_idx;
16 conn_idx{dim} = [1 3];
17 - if (p_size(dim) == 1 || ! any (conn(conn_idx{:})(:)))
18 + if (! any (conn(conn_idx{:})(:)))
19 continue
20 endif
21
22 @@ -262,3 +262,23 @@
23 %! c = a;
24 %! c(3:6,3:6,3) = false;
25 %! assert (bwperim (a, 4), c)
26 +
27 +## test dimensions of length 1 (1x1, Nx1, etc) (bug #50153)
28 +%!test
29 +%! conn_self = logical ([0 0 0; 0 1 0; 0 0 0]);
30 +%! assert (bwperim (true), true)
31 +%! assert (bwperim (true, conn_self), false)
32 +%! assert (bwperim (true (1, 6)), true (1, 6))
33 +%! assert (bwperim (true (1, 6), conn_self), false (1, 6))
34 +%! assert (bwperim (true (6, 1)), true (6, 1))
35 +%!
36 +%! bw_3d = true (1, 1, 6);
37 +%! assert (bwperim (bw_3d), bw_3d)
38 +%! assert (bwperim (bw_3d, conn_self), false (1, 1, 6))
39 +%! assert (bwperim (bw_3d, true (3)), bw_3d)
40 +%!
41 +%! perim_3d = bw_3d;
42 +%! perim_3d(1, 1, 2:end-1) = false;
43 +%! conn_3d = false (3, 3, 3);
44 +%! conn_3d(2, 2, :) = true;
45 +%! assert (bwperim (true (1, 1, 6), conn_3d), perim_3d)
46 diff -r c8bc315fa273 src/config.h.in
47 --- a/src/config.h.in Sat Feb 11 23:54:52 2017 +0000
48 +++ b/src/config.h.in Sun Apr 09 09:03:52 2017 -0400
49 @@ -1,2 +1,5 @@
50 /* Define if octave::math::min exists as replacement to xmin. */
51 #undef HAVE_MIN_IN_OCTAVE_MATH_NAMESPACE
52 +
53 +/* Define if octave::feval exists as replacement to feval. */
54 +#undef HAVE_FEVAL_IN_OCTAVE_NAMESPACE
55 diff -r c8bc315fa273 src/configure.ac
56 --- a/src/configure.ac Sat Feb 11 23:54:52 2017 +0000
57 +++ b/src/configure.ac Sun Apr 09 09:03:52 2017 -0400
58 @@ -70,6 +70,20 @@
59 [Define if octave::math::min exists as replacement to xmin.])
60 fi
61
62 +AC_CACHE_CHECK(
63 + [whether feval is in the octave namespace],
64 + [octave_image_cv_feval_in_octave_namespace],
65 + [AC_COMPILE_IFELSE(
66 + [AC_LANG_PROGRAM([#include <parse.h>],
67 + [octave::feval ("eye")])],
68 + [octave_image_cv_feval_in_octave_namespace=yes],
69 + [octave_image_cv_feval_in_octave_namespace=no])])
70 +
71 +if test "$octave_image_cv_feval_in_octave_namespace" = yes; then
72 + AC_DEFINE([HAVE_FEVAL_IN_OCTAVE_NAMESPACE], [1],
73 + [Define if octave::feval exists as replacement to feval.])
74 +fi
75 +
76 CXXFLAGS="$image_save_CXXFLAGS"
77
78
79 diff -r c8bc315fa273 src/imreconstruct.cc
80 --- a/src/imreconstruct.cc Sat Feb 11 23:54:52 2017 +0000
81 +++ b/src/imreconstruct.cc Sun Apr 09 09:03:52 2017 -0400
82 @@ -24,8 +24,6 @@
83 // This should still be more efficient than using subscript indices to find
84 // when we are on the border.
85
86 -#include "config.h"
87 -
88 #include <functional>
89 #include <queue>
90
91 @@ -38,20 +36,8 @@
92
93 using namespace octave::image;
94
95 -namespace octave_image
96 -{
97 - // Temporary wrapper until we no longer support Octave 4.0 (bug #48618)
98 - template <typename T>
99 - inline T
100 - min (T x, T y)
101 - {
102 -#if defined HAVE_MIN_IN_OCTAVE_MATH_NAMESPACE
103 - return octave::math::min (x, y);
104 -#else
105 - return xmin (x, y);
106 -#endif
107 - }
108 -}
109 +#define WANTS_MIN 1
110 +#include "octave-wrappers.h"
111
112 /*
113 ## A dirty implementation of the fast hybrid reconstruction as m file
114 diff -r c8bc315fa273 src/octave-wrappers.h
115 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
116 +++ b/src/octave-wrappers.h Sun Apr 09 09:03:52 2017 -0400
117 @@ -0,0 +1,70 @@
118 +// Copyright (C) 2017 Carnë Draug <carandraug@octave.org>
119 +//
120 +// This program is free software; you can redistribute it and/or
121 +// modify it under the terms of the GNU General Public License as
122 +// published by the Free Software Foundation; either version 3 of the
123 +// License, or (at your option) any later version.
124 +//
125 +// This program is distributed in the hope that it will be useful, but
126 +// WITHOUT ANY WARRANTY; without even the implied warranty of
127 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
128 +// General Public License for more details.
129 +//
130 +// You should have received a copy of the GNU General Public License
131 +// along with this program; if not, see
132 +// <http://www.gnu.org/licenses/>.
133 +
134 +// Core is going through a bunch of changes, and moving a lot of
135 +// functions into the octave namespace and deprecating thw old
136 +// functions. We want to be compatible with older versions and we
137 +// don't want to scare users with deprecation warnings so we have our
138 +// own wrappers so nothing breaks.
139 +//
140 +// We don't want to have a file per function we need to wrap; we don't
141 +// want to repeat the wrapper in each file that needs it; we don't
142 +// want to disable the deprecation warnings (so that we get warnings
143 +// next time we something else gets deprecated); and we don't want to
144 +// include all needed headers.
145 +//
146 +// It is the job of the file that includes this to include the
147 +// required headers, at least as long as core only changes the
148 +// namespace and not the header file.
149 +//
150 +// This wrappers are all temporary until we no longer support the
151 +// Octave version that made the change.
152 +
153 +#include "config.h"
154 +
155 +namespace octave_image
156 +{
157 + // Temporary wrapper until we no longer support Octave 4.0 (bug #48618)
158 +#if defined WANTS_MIN && ! defined HAS_MIN
159 +#define HAS_MIN 1
160 + template <typename T>
161 + inline T
162 + min (T x, T y)
163 + {
164 +#if defined HAVE_MIN_IN_OCTAVE_MATH_NAMESPACE
165 + return octave::math::min (x, y);
166 +#else
167 + return xmin (x, y);
168 +#endif
169 + }
170 +#endif
171 +
172 + // Temporary wrapper until we no longer support Octave 4.2 (bug #50180)
173 +#if defined WANTS_FEVAL && ! defined HAS_FEVAL
174 +#define HAS_FEVAL 1
175 + inline octave_value_list
176 + feval (const std::string& name,
177 + const octave_value_list& args,
178 + int nargout = 0)
179 + {
180 +#if defined HAVE_FEVAL_IN_OCTAVE_NAMESPACE
181 + return octave::feval (name, args, nargout);
182 +#else
183 + return ::feval (name, args, nargout);
184 +#endif
185 + }
186 +#endif
187 +}
188 diff -r c8bc315fa273 src/strel.cc
189 --- a/src/strel.cc Sat Feb 11 23:54:52 2017 +0000
190 +++ b/src/strel.cc Sun Apr 09 09:03:52 2017 -0400
191 @@ -27,6 +27,9 @@
192 #include <octave/parse.h> // gives us feval so we can use @strel
193 #include <octave/oct-map.h>
194
195 +#define WANTS_FEVAL 1
196 +#include "octave-wrappers.h"
197 +
198 // Constructors
199
200 // Expects a @strel object, or a boolean matrix (or something
201 @@ -49,13 +52,13 @@
5 strel_args(0) = "arbitrary"; 202 strel_args(0) = "arbitrary";
6 strel_args(1) = se; 203 strel_args(1) = se;
7 // We are leaving the input check up to @strel 204 // We are leaving the input check up to @strel
8 - se = feval ("strel", strel_args)(0); 205 - se = feval ("strel", strel_args)(0);
9 + se = octave::feval ("strel", strel_args)(0); 206 + se = octave_image::feval ("strel", strel_args)(0);
10 if (error_state) 207 if (error_state)
11 return; 208 return;
12 } 209 }
13 210
14 - nhood = feval ("getnhood", se)(0).bool_array_value (); 211 - nhood = feval ("getnhood", se)(0).bool_array_value ();
15 - height = feval ("getheight", se)(0).array_value (); 212 - height = feval ("getheight", se)(0).array_value ();
16 + nhood = octave::feval ("getnhood", se)(0).bool_array_value (); 213 + nhood = octave_image::feval ("getnhood", se)(0).bool_array_value ();
17 + height = octave::feval ("getheight", se)(0).array_value (); 214 + height = octave_image::feval ("getheight", se)(0).array_value ();
18 215
19 // Maybe we should handle this better but how? This makes imerode 216 // Maybe we should handle this better but how? This makes imerode
20 // and imdilate work with a [] strel 217 // and imdilate work with a [] strel
21 @@ -68,8 +68,8 @@ 218 @@ -68,8 +71,9 @@
22 ini_ctor (); 219 ini_ctor ();
23 origin = default_origin (); 220 origin = default_origin ();
24 221
25 - const octave_value se_seq = feval ("getsequence", se)(0); 222 - const octave_value se_seq = feval ("getsequence", se)(0);
26 - const octave_idx_type seq_numel = feval ("numel", se_seq)(0).idx_type_value (); 223 - const octave_idx_type seq_numel = feval ("numel", se_seq)(0).idx_type_value ();
27 + const octave_value se_seq = octave::feval ("getsequence", se)(0); 224 + const octave_value se_seq = octave_image::feval ("getsequence", se)(0);
28 + const octave_idx_type seq_numel = octave::feval ("numel", se_seq)(0).idx_type_value (); 225 + const octave_idx_type seq_numel
226 + = octave_image::feval ("numel", se_seq)(0).idx_type_value ();
29 227
30 // This is to emulate the strel_obj(idx) syntax in function form 228 // This is to emulate the strel_obj(idx) syntax in function form
31 static const char *fields[] = {"type", "subs", 0}; 229 static const char *fields[] = {"type", "subs", 0};
32 @@ -86,10 +86,10 @@ 230 @@ -86,10 +90,13 @@
33 ref.setfield ("subs", Cell (octave_value (subs+1))); 231 ref.setfield ("subs", Cell (octave_value (subs+1)));
34 subsref_args(1) = ref; 232 subsref_args(1) = ref;
35 // Equivalent to "selem = strel_obj(subs)" 233 // Equivalent to "selem = strel_obj(subs)"
36 - const octave_value_list elem = feval ("subsref", subsref_args)(0); 234 - const octave_value_list elem = feval ("subsref", subsref_args)(0);
37 + const octave_value_list elem = octave::feval ("subsref", subsref_args)(0); 235 + const octave_value_list elem
236 + = octave_image::feval ("subsref", subsref_args)(0);
38 237
39 - const boolNDArray elem_nhood = feval ("getnhood", elem)(0).bool_array_value (); 238 - const boolNDArray elem_nhood = feval ("getnhood", elem)(0).bool_array_value ();
40 - const NDArray elem_height = feval ("getheight", elem)(0).array_value (); 239 - const NDArray elem_height = feval ("getheight", elem)(0).array_value ();
41 + const boolNDArray elem_nhood = octave::feval ("getnhood", elem)(0).bool_array_value (); 240 + const boolNDArray elem_nhood
42 + const NDArray elem_height = octave::feval ("getheight", elem)(0).array_value (); 241 + = octave_image::feval ("getnhood", elem)(0).bool_array_value ();
242 + const NDArray elem_height
243 + = octave_image::feval ("getheight", elem)(0).array_value ();
43 244
44 decomposition.push_back (strel (elem_nhood, elem_height)); 245 decomposition.push_back (strel (elem_nhood, elem_height));
45 } 246 }
46 diff -uNr a/src/watershed.cc b/src/watershed.cc 247 diff -r c8bc315fa273 src/watershed.cc
47 --- a/src/watershed.cc 2016-10-21 10:19:56.258205086 -0400 248 --- a/src/watershed.cc Sat Feb 11 23:54:52 2017 +0000
48 +++ b/src/watershed.cc 2017-03-10 11:13:10.433094696 -0500 249 +++ b/src/watershed.cc Sun Apr 09 09:03:52 2017 -0400
49 @@ -57,7 +57,7 @@ 250 @@ -21,6 +21,9 @@
251 #include <octave/Cell.h>
252 #include <octave/oct-map.h>
253
254 +#define WANTS_FEVAL 1
255 +#include "octave-wrappers.h"
256 +
257 #include "connectivity.h"
258 using namespace octave::image;
259
260 @@ -57,7 +60,7 @@
50 args(0) = im; 261 args(0) = im;
51 args(1) = conn.mask; 262 args(1) = conn.mask;
52 args(2) = conn.mask; 263 args(2) = conn.mask;
53 - const octave_value gradient = feval ("mmgradm", args)(0); 264 - const octave_value gradient = feval ("mmgradm", args)(0);
54 + const octave_value gradient = octave::feval ("mmgradm", args)(0); 265 + const octave_value gradient = octave_image::feval ("mmgradm", args)(0);
55 return ov2T<T> (gradient); 266 return ov2T<T> (gradient);
56 } 267 }
57 268
58 @@ -68,7 +68,7 @@ 269 @@ -68,7 +71,8 @@
59 octave_value_list args (2); 270 octave_value_list args (2);
60 args(0) = im; 271 args(0) = im;
61 args(1) = conn.mask; 272 args(1) = conn.mask;
62 - const octave_value regional_min = feval ("imregionalmin", args)(0); 273 - const octave_value regional_min = feval ("imregionalmin", args)(0);
63 + const octave_value regional_min = octave::feval ("imregionalmin", args)(0); 274 + const octave_value regional_min = octave_image::feval ("imregionalmin",
275 + args)(0);
64 return regional_min.bool_array_value (); 276 return regional_min.bool_array_value ();
65 } 277 }
66 278
67 @@ -78,7 +78,7 @@ 279 @@ -78,7 +82,7 @@
68 octave_value_list args (2); 280 octave_value_list args (2);
69 args(0) = bw; 281 args(0) = bw;
70 args(1) = conn.mask; 282 args(1) = conn.mask;
71 - const octave_value label = feval ("bwlabeln", args)(0); 283 - const octave_value label = feval ("bwlabeln", args)(0);
72 + const octave_value label = octave::feval ("bwlabeln", args)(0); 284 + const octave_value label = octave_image::feval ("bwlabeln", args)(0);
73 return label.array_value (); 285 return label.array_value ();
74 } 286 }
75 287