Mercurial > mxe-octave
annotate 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 |
rev | line source |
---|---|
4378 | 1 diff -r c8bc315fa273 inst/bwperim.m |
2 --- a/inst/bwperim.m Sat Feb 11 23:54:52 2017 +0000 | |
3 +++ b/inst/bwperim.m Sun Apr 09 09:03:52 2017 -0400 | |
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 @@ | |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 strel_args(0) = "arbitrary"; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 strel_args(1) = se; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 // We are leaving the input check up to @strel |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 - se = feval ("strel", strel_args)(0); |
4378 | 206 + se = octave_image::feval ("strel", strel_args)(0); |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 if (error_state) |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 return; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 } |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 - nhood = feval ("getnhood", se)(0).bool_array_value (); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 - height = feval ("getheight", se)(0).array_value (); |
4378 | 213 + nhood = octave_image::feval ("getnhood", se)(0).bool_array_value (); |
214 + height = octave_image::feval ("getheight", se)(0).array_value (); | |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 // Maybe we should handle this better but how? This makes imerode |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 // and imdilate work with a [] strel |
4378 | 218 @@ -68,8 +71,9 @@ |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 ini_ctor (); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 origin = default_origin (); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 - const octave_value se_seq = feval ("getsequence", se)(0); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 - const octave_idx_type seq_numel = feval ("numel", se_seq)(0).idx_type_value (); |
4378 | 224 + const octave_value se_seq = octave_image::feval ("getsequence", se)(0); |
225 + const octave_idx_type seq_numel | |
226 + = octave_image::feval ("numel", se_seq)(0).idx_type_value (); | |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 // This is to emulate the strel_obj(idx) syntax in function form |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 static const char *fields[] = {"type", "subs", 0}; |
4378 | 230 @@ -86,10 +90,13 @@ |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 ref.setfield ("subs", Cell (octave_value (subs+1))); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 subsref_args(1) = ref; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 // Equivalent to "selem = strel_obj(subs)" |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 - const octave_value_list elem = feval ("subsref", subsref_args)(0); |
4378 | 235 + const octave_value_list elem |
236 + = octave_image::feval ("subsref", subsref_args)(0); | |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 - const boolNDArray elem_nhood = feval ("getnhood", elem)(0).bool_array_value (); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 - const NDArray elem_height = feval ("getheight", elem)(0).array_value (); |
4378 | 240 + const boolNDArray elem_nhood |
241 + = octave_image::feval ("getnhood", elem)(0).bool_array_value (); | |
242 + const NDArray elem_height | |
243 + = octave_image::feval ("getheight", elem)(0).array_value (); | |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 decomposition.push_back (strel (elem_nhood, elem_height)); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 } |
4378 | 247 diff -r c8bc315fa273 src/watershed.cc |
248 --- a/src/watershed.cc Sat Feb 11 23:54:52 2017 +0000 | |
249 +++ b/src/watershed.cc Sun Apr 09 09:03:52 2017 -0400 | |
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 @@ | |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 args(0) = im; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 args(1) = conn.mask; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 args(2) = conn.mask; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 - const octave_value gradient = feval ("mmgradm", args)(0); |
4378 | 265 + const octave_value gradient = octave_image::feval ("mmgradm", args)(0); |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
266 return ov2T<T> (gradient); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 } |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 |
4378 | 269 @@ -68,7 +71,8 @@ |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 octave_value_list args (2); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 args(0) = im; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 args(1) = conn.mask; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
273 - const octave_value regional_min = feval ("imregionalmin", args)(0); |
4378 | 274 + const octave_value regional_min = octave_image::feval ("imregionalmin", |
275 + args)(0); | |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
276 return regional_min.bool_array_value (); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 } |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 |
4378 | 279 @@ -78,7 +82,7 @@ |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 octave_value_list args (2); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 args(0) = bw; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 args(1) = conn.mask; |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 - const octave_value label = feval ("bwlabeln", args)(0); |
4378 | 284 + const octave_value label = octave_image::feval ("bwlabeln", args)(0); |
4357
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 return label.array_value (); |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 } |
74c7af6a36c0
* of-image-1-fixes.patch: New file.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 |