projects
/
master-thesis.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Piaz files wasn't associated during setup.
[master-thesis.git]
/
Parasitemia
/
ParasitemiaCore
/
ImgTools
/
Edges.fs
diff --git
a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
index
b174ee9
..
df5858d
100644
(file)
--- a/
Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
+++ b/
Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
@@
-11,6
+11,10
@@
open Const
open Histogram
open Otsu
open Histogram
open Otsu
+// Sensibilities of the hysteresis search.
+let sensibilityHigh = 0.1f
+let sensibilityLow = 0.0f
+
/// <summary>
/// Find edges of an image by using the Canny approach.
/// The thresholds are automatically defined with otsu on gradient magnitudes.
/// <summary>
/// Find edges of an image by using the Canny approach.
/// The thresholds are automatically defined with otsu on gradient magnitudes.
@@
-21,9
+25,9
@@
let find (img: Image<Gray, float32>) : Matrix<byte> * Matrix<float32> * Matrix<f
let h = img.Height
use sobelKernel =
let h = img.Height
use sobelKernel =
- new Matrix<float32>(array2D [[
1.0f; 0.0f; -
1.0f ]
- [
2.0f; 0.0f; -
2.0f ]
- [
1.0f; 0.0f; -
1.0f ]])
+ new Matrix<float32>(array2D [[
-1.0f; 0.0f;
1.0f ]
+ [
-2.0f; 0.0f;
2.0f ]
+ [
-1.0f; 0.0f;
1.0f ]])
let xGradient = new Matrix<float32>(img.Size)
let yGradient = new Matrix<float32>(img.Size)
let xGradient = new Matrix<float32>(img.Size)
let yGradient = new Matrix<float32>(img.Size)
@@
-32,11
+36,9
@@
let find (img: Image<Gray, float32>) : Matrix<byte> * Matrix<float32> * Matrix<f
use magnitudes = new Matrix<float32>(xGradient.Size)
use angles = new Matrix<float32>(xGradient.Size)
use magnitudes = new Matrix<float32>(xGradient.Size)
use angles = new Matrix<float32>(xGradient.Size)
- CvInvoke.CartToPolar(xGradient, yGradient, magnitudes, angles) // Compute the magnitudes and angles.
+ CvInvoke.CartToPolar(xGradient, yGradient, magnitudes, angles) // Compute the magnitudes and angles.
The angles are between 0 and 2 * pi.
let thresholdHigh, thresholdLow =
let thresholdHigh, thresholdLow =
- let sensibilityHigh = 0.1f
- let sensibilityLow = 0.0f
let threshold, _, _ = otsu (histogramMat magnitudes 300)
threshold + (sensibilityHigh * threshold), threshold - (sensibilityLow * threshold)
let threshold, _, _ = otsu (histogramMat magnitudes 300)
threshold + (sensibilityHigh * threshold), threshold - (sensibilityLow * threshold)
@@
-49,16
+51,8
@@
let find (img: Image<Gray, float32>) : Matrix<byte> * Matrix<float32> * Matrix<f
let xGradientData = xGradient.Data
let yGradientData = yGradient.Data
let xGradientData = xGradient.Data
let yGradientData = yGradient.Data
- for i in 0 .. h - 1 do
- nmsData.[i, 0] <- 0uy
- nmsData.[i, w - 1] <- 0uy
-
- for j in 0 .. w - 1 do
- nmsData.[0, j] <- 0uy
- nmsData.[h - 1, j] <- 0uy
-
- for i in 1 .. h - 2 do
- for j in 1 .. w - 2 do
+ for i = 1 to h - 2 do
+ for j = 1 to w - 2 do
let vx = xGradientData.[i, j]
let vy = yGradientData.[i, j]
if vx <> 0.f || vy <> 0.f
let vx = xGradientData.[i, j]
let vy = yGradientData.[i, j]
if vx <> 0.f || vy <> 0.f
@@
-98,8
+92,8
@@
let find (img: Image<Gray, float32>) : Matrix<byte> * Matrix<float32> * Matrix<f
// Hysteresis thresholding.
let toVisit = Stack<Point>()
// Hysteresis thresholding.
let toVisit = Stack<Point>()
- for i
in 0 ..
h - 1 do
- for j
in 0 ..
w - 1 do
+ for i
= 0 to
h - 1 do
+ for j
= 0 to
w - 1 do
if nmsData.[i, j] = 1uy && magnitudesData.[i, j] >= thresholdHigh
then
nmsData.[i, j] <- 0uy
if nmsData.[i, j] = 1uy && magnitudesData.[i, j] >= thresholdHigh
then
nmsData.[i, j] <- 0uy
@@
-107,8
+101,8
@@
let find (img: Image<Gray, float32>) : Matrix<byte> * Matrix<float32> * Matrix<f
while toVisit.Count > 0 do
let p = toVisit.Pop()
edgesData.[p.Y, p.X] <- 1uy
while toVisit.Count > 0 do
let p = toVisit.Pop()
edgesData.[p.Y, p.X] <- 1uy
- for i'
in -1 ..
1 do
- for j'
in -1 ..
1 do
+ for i'
= -1 to
1 do
+ for j'
= -1 to
1 do
if i' <> 0 || j' <> 0
then
let ni = p.Y + i'
if i' <> 0 || j' <> 0
then
let ni = p.Y + i'