X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FImgTools%2FEdges.fs;h=a1b60336590b5f6b31c68947ab1b40c859c218f4;hp=b174ee9d060ed08ad4541b3e45112465cbe8a943;hb=04d4504e7b248a82ddfc1a41d325e59d24146590;hpb=276f1c9741f196e022bdbd175b4f6ef0ebb6367d diff --git a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs index b174ee9..a1b6033 100644 --- a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs +++ b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs @@ -11,6 +11,10 @@ open Const open Histogram open Otsu +// Sensibilities of the hysteresis search. +let sensibilityHigh = 0.1f +let sensibilityLow = 0.0f + /// /// 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) : Matrix * Matrix * Matrix(array2D [[ 1.0f; 0.0f; -1.0f ] - [ 2.0f; 0.0f; -2.0f ] - [ 1.0f; 0.0f; -1.0f ]]) + new Matrix(array2D [[ -1.0f; 0.0f; 1.0f ] + [ -2.0f; 0.0f; 2.0f ] + [ -1.0f; 0.0f; 1.0f ]]) let xGradient = new Matrix(img.Size) let yGradient = new Matrix(img.Size) @@ -32,11 +36,9 @@ let find (img: Image) : Matrix * Matrix * Matrix(xGradient.Size) use angles = new Matrix(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 sensibilityHigh = 0.1f - let sensibilityLow = 0.0f let threshold, _, _ = otsu (histogramMat magnitudes 300) threshold + (sensibilityHigh * threshold), threshold - (sensibilityLow * threshold) @@ -49,14 +51,6 @@ let find (img: Image) : Matrix * Matrix * Matrix) : Matrix * Matrix * Matrix(xGradient.Size) let edgesData = edges.Data