You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ArrayFire/Vision.hs
+59-1Lines changed: 59 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -158,13 +158,36 @@ matchTemplate
158
158
matchTemplate a b (fromMatchType -> match)
159
159
= op2 a b (\p c d -> af_match_template p c d match)
160
160
161
+
--| SUSAN corner detector.
162
+
--
163
+
-- SUSAN is an acronym standing for Smallest Univalue Segment Assimilating Nucleus. This method places a circular disc over the pixel to be tested (a.k.a nucleus) to compute the corner measure of that corresponding pixel. The region covered by the circular disc is M, and a pixel in this region is represented by m⃗ ∈M where m⃗ 0 is the nucleus. Every pixel in the region is compared to the nucleus using the following comparison function:
164
+
--
165
+
-- c(m⃗ )=e−((I(m⃗ )−I(m⃗ 0))/t)6
166
+
-- where t is radius of the region, I is the brightness of the pixel.
167
+
--
168
+
-- Response of SUSAN operator is given by the following equation:
169
+
--
170
+
-- R(M)={g−n(M)if n(M)<g0otherwise,
171
+
-- where n(M)=∑m⃗ ∈Mc(m⃗ ), g is named the geometric threshold and n is the number of pixels in the mask which are within t of the nucleus.
172
+
--
173
+
-- Importance of the parameters, t and g is explained below:
174
+
--
175
+
-- t determines how similar points have to be to the nucleusbefore they are considered to be a part of the univalue segment
176
+
--
177
+
-- g determines the minimum size of the univalue segment. For a large enough g, SUSAN operator becomes an edge dectector.
161
178
susan
162
179
::Arraya
180
+
--^ is input grayscale/intensity image
163
181
->Int
182
+
--^ nucleus radius for each pixel neighborhood
164
183
->Float
184
+
--^ intensity difference threshold a.k.a t from equations in description
165
185
->Float
186
+
--^ geometric threshold
166
187
->Float
188
+
--^ is maximum number of features that will be returned by the function
167
189
->Int
190
+
--^ indicates how many pixels width area should be skipped for corner detection
168
191
->Features
169
192
susan (Array fptr) (fromIntegral-> a) b c d (fromIntegral-> e)
-- Given an image, this function computes two different versions of smoothed input image using the difference smoothing parameters and subtracts one from the other and returns the result.
203
+
--
177
204
dog
178
205
::Arraya
206
+
--^ is input image
179
207
->Int
208
+
--^ is the radius of first gaussian kernel
180
209
->Int
210
+
--^ is the radius of second gaussian kernel
181
211
->Arraya
182
-
dog a (fromIntegral-> x) (fromIntegral-> y) =
212
+
--^ is difference of smoothed inputs
213
+
dog a (fromIntegral-> x) (fromIntegral-> y) =
183
214
op1 a (\p c -> af_dog p c x y)
184
215
216
+
--| Homography Estimation.
217
+
--
218
+
-- Homography estimation find a perspective transform between two sets of 2D points.
219
+
-- Currently, two methods are supported for the estimation, RANSAC (RANdom SAmple Consensus)
220
+
-- and LMedS (Least Median of Squares). Both methods work by randomly selecting a subset of 4 points
221
+
-- of the set of source points, computing the eigenvectors of that set and finding the perspective transform.
222
+
-- The process is repeated several times, a maximum of times given by the value passed to the iterations arguments
223
+
-- for RANSAC (for the CPU backend, usually less than that, depending on the quality of the dataset,
224
+
-- but for CUDA and OpenCL backends the transformation will be computed exactly the amount of times passed via
225
+
-- the iterations parameter), the returned value is the one that matches the best number of inliers, which are
226
+
-- all of the points that fall within a maximum L2 distance from the value passed to the inlier_thr argument.
227
+
-- For the LMedS case, the number of iterations is currently hardcoded to meet the following equation:
228
+
--
229
+
-- m=log(1−P)log[1−(1−ϵ)p],
230
+
--
231
+
-- where P=0.99, ϵ=40% and p=4.
185
232
homography
186
233
::foralla.AFTypea
187
234
=>Arraya
235
+
--^ x coordinates of the source points.
188
236
->Arraya
237
+
--^ y coordinates of the source points.
189
238
->Arraya
239
+
--^ x coordinates of the destination points.
190
240
->Arraya
241
+
--^ y coordinates of the destination points.
191
242
->HomographyType
243
+
--^ htype, can be AF_HOMOGRAPHY_RANSAC, for which a
244
+
-- RANdom SAmple Consensus will be used to evaluate
245
+
-- the homography quality (e.g., number of inliers),
246
+
-- or AF_HOMOGRAPHY_LMEDS, which will use
247
+
-- Least Median of Squares method to evaluate homography quality.
192
248
->Float
249
+
--^ If htype is AF_HOMOGRAPHY_RANSAC, this parameter will five the maximum L2-distance for a point to be considered an inlier.
193
250
->Int
251
+
--^ maximum number of iterations when htype is AF_HOMOGRAPHY_RANSAC and backend is CPU, if backend is CUDA or OpenCL, iterations is the total number of iterations, an iteration is a selection of 4 random points for which the homography is estimated and evaluated for number of inliers.
0 commit comments