Skip to content

Commit aead0ad

Browse files
Loop refactoring.
1 parent e5228ed commit aead0ad

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

source/dcv/features/rht.d

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ mixin template BaseRht()
108108
/// Run RHT using non-zero points in image as edge points.
109109
auto opCall(T)(Slice!(2, T*) image)
110110
{
111-
Point[] points;
112-
foreach (y; 0 .. image.length!0)
113-
foreach (x; 0 .. image.length!1)
111+
import std.array : appender;
112+
113+
auto points = appender!(Point[])();
114+
assumeSameStructure!("index", "value")(indexSlice(image.length!0, image.length!1), image).ndEach!((p) {
115+
if (p.value > 0)
114116
{
115-
if (image[y, x] > 0)
116-
{
117-
points ~= Point(cast(int)x, cast(int)y);
118-
}
117+
points.put(Point(cast(int)p.index[1], cast(int)p.index[0]));
119118
}
120-
return this.opCall(image, points);
119+
});
120+
return this.opCall(image, points.data);
121121
}
122122

123123
/// Run RHT using prepopullated array of edge points (that may be filtered beforehand).

0 commit comments

Comments
 (0)