Skip to content

Commit b3168ee

Browse files
authored
Merge pull request #193 from aferust/master
update docs finally
2 parents 99791a0 + 32d8136 commit b3168ee

File tree

18 files changed

+299
-101
lines changed

18 files changed

+299
-101
lines changed

docs/builddoc.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set DDOCFILE=dcv.ddoc
55
cd ../
66

77
dub --build=docs --compiler=ldc2 dcv:core
8-
dub --build=docs --compiler=ldc2 dcv:io
9-
dub --build=docs --compiler=ldc2 dcv:plot
8+
dub --build=docs --compiler=ldc2 dcv:imageio
9+
dub --build=docs --compiler=ldc2 dcv:linalg
1010

1111
cd docs

source/dcv/core/image.d

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
/**
22
Module implements Image utility class, and basic API for image manipulation.
33
Image class encapsulates image properties with minimal functionality. It is primarily designed to be used as I/O unit.
4-
For any image processing needs, image data can be sliced to mir.ndslice.slice.Slice.
4+
For any image processing needs, image data can be sliced to mir.ndslice.slice.Slice.
5+
If an Image instance is initialized with non-null ubyte[] data, this time,
6+
the Image instance behaves like a slice shell, and it does not attempt to deallocate the borrowed data slice.
57
Example:
68
----
7-
Image image = new Image(32, 32, ImageFormat.IF_MONO, BitDepth.BD_32);
8-
Slice!(float*, 3, Contiguous) slice = image.sliced!float; // slice image data, considering the data is of float type.
9+
Image image1 = new Image(32, 32, ImageFormat.IF_MONO, BitDepth.BD_32);
10+
Slice!(ubyte*, 3, Contiguous) slice = image1.sliced; // slice image data
11+
// Slice!(ubyte*, 2, Contiguous) slice = image1.sliced2D; // if it is known that the data represents a monochrome image
12+
913
assert(image.height == slice.length!0 && image.width == slice.length!1);
1014
assert(image.channels == 1);
11-
image = slice.asImage(ImageFormat.IF_MONO); // create the image back from sliced data.
15+
image2 = slice.asImage(ImageFormat.IF_MONO); // create the image back from sliced data.
16+
// asImage allocates with malloc, so it should be freed manually.
17+
destroyFree(image2)
18+
...
19+
20+
// here image3 is does neither copy nor own the someUbyteSlice.
21+
Image image3 = new Image(32, 32, ImageFormat.IF_MONO, BitDepth.BD_32, someUbyteSlice); // or mallocNew!Image(...);
22+
destroy(image3); // or destroyFree(image3) this does not attempt to free someUbyteSlice.
1223
----
1324
Copyright: Copyright Relja Ljubobratovic 2016.
14-
Authors: Relja Ljubobratovic
25+
Authors: Relja Ljubobratovic, Ferhat Kurtulmuş
1526
License: $(LINK3 http://www.boost.org/LICENSE_1_0.txt, Boost Software License - Version 1.0).
1627
*/
1728
module dcv.core.image;
@@ -260,9 +271,6 @@ public:
260271
Get data array from this image.
261272
Cast data array to corresponding dynamic array type,
262273
and return it.
263-
8-bit data is considered ubyte, 16-bit ushort, and 32-bit float.
264-
Params:
265-
T = (template parameter) value type (default ubyte) to which data array is casted to.
266274
*/
267275
inout auto data()
268276
{

source/dcv/features/package.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ module dcv.features;
66
* v0.1 norm:
77
* harris
88
* shi-tomasi
9-
* fast (wrap C version by author: http://www.edwardrosten.com/work/fast.html
9+
* fast $(LPAREN)wrap C version by author: http://www.edwardrosten.com/work/fast.html$(RPAREN)
1010
* most popular blob detectors - sift, ???
1111
* dense features - hog
1212
*
1313
* v0.1+:
14-
* other popular feature detectors, descriptor (surf, brief, orb, akaze, etc.)
14+
* other popular feature detectors, descriptor, such as surf, brief, orb, akaze, etc.
1515
*/
1616

1717
public import dcv.features.corner, dcv.features.utils, dcv.features.sift;

source/dcv/features/utils.d

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,19 @@ struct Feature
3838
float score;
3939
}
4040

41+
@nogc nothrow:
42+
4143
/**
4244
Extract corners as array of 2D points, from response matrix.
4345
4446
Params:
45-
cornerResponse = Response matrix, collected as output from corner
46-
detection algoritms such as harrisCorners, or shiTomasiCorners.
47-
count = Number of corners which need to be extracted. Default is
48-
-1 which indicate that all responses with value above the threshold
49-
will be returned.
50-
threshold = Response threshold - response values in the matrix
51-
larger than this are considered as valid corners.
52-
47+
cornerResponse = Response matrix, collected as output from corner detection algoritms such as harrisCorners, or shiTomasiCorners.
48+
count = Number of corners which need to be extracted. Default is -1 which indicate that all responses with value above the threshold will be returned.
49+
threshold = Response threshold - response values in the matrix larger than this are considered as valid corners.
5350
Returns:
54-
Lazy array of size_t[2], as in array of 2D points, of corner reponses
51+
RCArray!Pair, as in array of 2D points, of corner reponses
5552
which fit the given criteria.
5653
*/
57-
@nogc nothrow:
58-
5954
auto extractCorners(T)
6055
(
6156
Slice!(T*, 2, Contiguous) cornerResponse,
@@ -162,9 +157,16 @@ unittest
162157
assert(res[0] == [1, 1]);
163158
}
164159

165-
/++
166-
Returns euclidean distance between feature descriptor vectors.
167-
+/
160+
/**
161+
Compute the Euclidean distance between two feature descriptor vectors.
162+
163+
Params:
164+
desc1 = The first feature descriptor vector of const DescriptorValueType[].
165+
desc2 = The second feature descriptor vector of const DescriptorValueType[].
166+
167+
Returns:
168+
double = The Euclidean distance between the two feature descriptor vectors.
169+
*/
168170
double euclideanDistBetweenDescriptors(DescriptorValueType)(const DescriptorValueType[] desc1, const DescriptorValueType[] desc2)
169171
{
170172
double sum = 0;
@@ -176,9 +178,22 @@ double euclideanDistBetweenDescriptors(DescriptorValueType)(const DescriptorValu
176178
}
177179

178180
alias FeatureMatch = Tuple!(int, "index1", int, "index2", double, "distNearestNeighbor", double, "nearestNeighborDistanceRatio");
179-
/++
180-
Returns an Array containing matched indices of the given Keypoints with brute force approach.
181-
+/
181+
182+
/**
183+
Finds matching points between two sets of keypoints using the brute force approach.
184+
185+
This function matches keypoints from two sets by comparing each keypoint in the first set with every keypoint in the second set.
186+
187+
Params:
188+
keypoints1 = The first set of keypoints of const ref Array!KeyPoint .
189+
keypoints2 = The second set of keypoints of const ref Array!KeyPoint .
190+
threshold = The distance ratio threshold for determining matches. Defaults to 0.5.
191+
192+
Returns:
193+
Array!FeatureMatch = An array containing matched indices of keypoints. Each element in the array is a tuple
194+
containing the index of the keypoint from the first set, the index of the matching keypoint
195+
from the second set, the distance to the nearest neighbor, and the nearest neighbor distance ratio.
196+
*/
182197
Array!FeatureMatch
183198
find_MatchingPointsBruteForce(KeyPoint)(const ref Array!KeyPoint keypoints1,
184199
const ref Array!KeyPoint keypoints2, double threshold = 0.5)

source/dcv/imageio/image.d

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
Module for image I/O.
33
Copyright: Copyright Relja Ljubobratovic 2016.
4-
Authors: Relja Ljubobratovic
4+
Authors: Relja Ljubobratovic, Ferhat Kurtulmuş
55
License: $(LINK3 http://www.boost.org/LICENSE_1_0.txt, Boost Software License - Version 1.0).
66
*/
77
module dcv.imageio.image;
@@ -92,8 +92,6 @@ color format. To load original depth or format, set to _UNASSIGNED (ImageFormat.
9292
BitDepth.BD_UNASSIGNED).
9393
return:
9494
Image read from the filesystem.
95-
throws:
96-
Exception and ImageIOException from imageformats library.
9795
*/
9896
Image imread(in string path, ReadParams params = ReadParams(ImageFormat.IF_UNASSIGNED, BitDepth.BD_UNASSIGNED))
9997
{

source/dcv/imgproc/convolution.d

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ Following example loads famous image of Lena Söderberg and performs gaussian bl
55
66
----
77
import dcv.imageio.image : imread, ReadParams;
8-
import dcv.core.image : Image, asType;
8+
import dcv.core.image : Image;
99
import dcv.imgproc.convolution : conv;
1010
1111
Image lenaImage = imread("../data/lena.png", ReadParams(ImageFormat.IF_MONO, BitDepth.BD_8));
12-
auto slice = lenaImage.sliced!ubyte;
12+
auto slice = lenaImage.sliced;
1313
----
1414
1515
... this loads the following image:<br>
1616
$(IMAGE https://github.com/libmir/dcv/blob/master/examples/data/lena.png?raw=true)
1717
1818
----
1919
blurred = slice
20-
.asType!float // convert ubyte data to float.
20+
.as!float // convert ubyte data to float.
2121
.conv(gaussian!float(0.84f, 5, 5)); // convolve image with gaussian kernel
2222
2323
----
@@ -69,7 +69,6 @@ Params:
6969
prealloc is not of same shape as input input, resulting array will be newly allocated.
7070
mask = Masking input. Convolution will skip each element where mask is 0. Default value
7171
is empty slice, which tells that convolution will be performed on the whole input.
72-
pool = Optional TaskPool instance used to parallelize computation.
7372
7473
Returns:
7574
Resulting image after convolution, of same type as input tensor.

source/dcv/imgproc/filter.d

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ Params:
527527
Default value is EdgeKernel.SIMPLE, which calls calcPartialDerivatives function
528528
to calculate derivatives. Other options will perform convolution with requested
529529
kernel type.
530-
pool = TaskPool instance used parallelise the algorithm.
531530
532531
Note:
533532
Input slice's memory has to be contiguous. Magnitude and orientation slices' strides
@@ -615,7 +614,6 @@ Params:
615614
mag = Gradient magnitude.
616615
orient = Gradient orientation of the same image source as magnitude.
617616
prealloc = Optional pre-allocated buffer for output slice.
618-
pool = TaskPool instance used parallelise the algorithm.
619617
620618
Note:
621619
Orientation and pre-allocated structures must match. If prealloc
@@ -684,7 +682,6 @@ Params:
684682
upThresh = upper threshold value after non-maxima suppression.
685683
edgeKernelType = Type of edge kernel used to calculate image gradients.
686684
prealloc = Optional pre-allocated buffer.
687-
pool = TaskPool instance used parallelise the algorithm.
688685
*/
689686
@nogc nothrow
690687
Slice!(RCI!V, 2LU, Contiguous) canny(V, T, SliceKind kind)
@@ -738,7 +735,6 @@ Params:
738735
sigmaSpace = Spatial sigma value.
739736
kernelSize = Size of convolution kernel. Must be odd number.
740737
prealloc = Optional pre-allocated result image buffer. If not of same shape as input slice, its allocated anew.
741-
pool = Optional TaskPool instance used to parallelize computation.
742738
743739
Returns:
744740
Slice of filtered image.
@@ -861,7 +857,6 @@ Params:
861857
slice = Input image slice.
862858
kernelSize = Square size of median kernel.
863859
prealloc = Optional pre-allocated return image buffer.
864-
pool = Optional TaskPool instance used to parallelize computation.
865860
866861
Returns:
867862
Returns filtered image of same size as the input. If prealloc parameter is not an empty slice, and is
@@ -1122,7 +1117,6 @@ Params:
11221117
slice = Input image slice, to be eroded.
11231118
kernel = Erosion kernel. Default value is radialKernel!T(3).
11241119
prealloc = Optional pre-allocated buffer to hold result.
1125-
pool = Optional TaskPool instance used to parallelize computation.
11261120
11271121
Returns:
11281122
Eroded image slice, of same type as input image.
@@ -1187,7 +1181,6 @@ Params:
11871181
slice = Input image slice, to be eroded.
11881182
kernel = Dilation kernel. Default value is radialKernel!T(3).
11891183
prealloc = Optional pre-allocated buffer to hold result.
1190-
pool = Optional TaskPool instance used to parallelize computation.
11911184
11921185
Returns:
11931186
Dilated image slice, of same type as input image.
@@ -1216,7 +1209,6 @@ Params:
12161209
slice = Input image slice, to be eroded.
12171210
kernel = Erosion/Dilation kernel. Default value is radialKernel!T(3).
12181211
prealloc = Optional pre-allocated buffer to hold result.
1219-
pool = Optional TaskPool instance used to parallelize computation.
12201212
12211213
Returns:
12221214
Opened image slice, of same type as input image.
@@ -1246,7 +1238,6 @@ Params:
12461238
slice = Input image slice, to be eroded.
12471239
kernel = Erosion/Dilation kernel. Default value is radialKernel!T(3).
12481240
prealloc = Optional pre-allocated buffer to hold result.
1249-
pool = Optional TaskPool instance used to parallelize computation.
12501241
12511242
Returns:
12521243
Closed image slice, of same type as input image.

source/dcv/imgproc/interpolate.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Linear interpolation.
5656
5757
Params:
5858
slice = Input slice which values are interpolated.
59-
pos = Position on which slice values are interpolated.
59+
pos0 = Position on which slice values are interpolated.
6060
6161
Returns:
6262
Interpolated resulting value.

source/dcv/imgproc/threshold.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Image thresholding module.
33
44
Copyright: Copyright Relja Ljubobratovic 2016.
55
6-
Authors: Relja Ljubobratovic
6+
Authors: Relja Ljubobratovic, Ferhat Kurtulmuş
77
88
License: $(LINK3 http://www.boost.org/LICENSE_1_0.txt, Boost Software License - Version 1.0).
99
*/
@@ -36,6 +36,7 @@ Params:
3636
input = Input slice.
3737
lowThresh = Lower threshold value.
3838
highThresh = Higher threshold value.
39+
inverse = A flag to set output image as a negative binary image
3940
prealloc = Optional pre-allocated slice buffer for output.
4041
4142
Note:
@@ -109,6 +110,7 @@ Calls threshold(slice, thresh, thresh, prealloc)
109110
Params:
110111
input = Input slice.
111112
thresh = Threshold value - any value lower than this will be set to 0, and higher to 1.
113+
inverse = A flag to set output image as a negative binary image
112114
prealloc = Optional pre-allocated slice buffer for output.
113115
114116
Note:

0 commit comments

Comments
 (0)