|
|
|
@ -20,6 +20,9 @@ namespace OpenCV |
|
|
|
|
IplImage draw; |
|
|
|
|
IplImage hsv; |
|
|
|
|
IplImage hsvRed; |
|
|
|
|
IplImage morp; |
|
|
|
|
|
|
|
|
|
IplConvKernel convKernel; |
|
|
|
|
|
|
|
|
|
public IplImage GrayScale(IplImage src) |
|
|
|
|
{ |
|
|
|
@ -35,10 +38,10 @@ namespace OpenCV |
|
|
|
|
return inversion; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IplImage Binary(IplImage src) |
|
|
|
|
public IplImage Binary(IplImage src, int threshold) |
|
|
|
|
{ |
|
|
|
|
bin = GrayScale(src); |
|
|
|
|
Cv.Threshold(bin, bin, 150, 255, ThresholdType.Binary); |
|
|
|
|
Cv.Threshold(bin, bin, threshold, 255, ThresholdType.Binary); |
|
|
|
|
return bin; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -206,6 +209,44 @@ namespace OpenCV |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IplImage DilateImage(IplImage src, int threshold, int iteration) |
|
|
|
|
{ |
|
|
|
|
morp = new IplImage(src.Size, BitDepth.U8, 1); |
|
|
|
|
bin = Binary(src, threshold); |
|
|
|
|
Cv.Dilate(bin, morp, convKernel, iteration); |
|
|
|
|
|
|
|
|
|
return morp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IplImage ErodeImage(IplImage src, int threshold, int iteration) |
|
|
|
|
{ |
|
|
|
|
morp = new IplImage(src.Size, BitDepth.U8, 1); |
|
|
|
|
bin = Binary(src, threshold); |
|
|
|
|
Cv.Erode(bin, morp, convKernel, iteration); |
|
|
|
|
|
|
|
|
|
return morp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IplImage DEImage(IplImage src, int threshold, int iteration) |
|
|
|
|
{ |
|
|
|
|
morp = new IplImage(src.Size, BitDepth.U8, 1); |
|
|
|
|
bin = Binary(src, threshold); |
|
|
|
|
Cv.Dilate(bin, morp, convKernel, iteration); |
|
|
|
|
Cv.Erode(morp, morp, convKernel, iteration); |
|
|
|
|
|
|
|
|
|
return morp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IplImage EDImage(IplImage src, int threshold, int iteration) |
|
|
|
|
{ |
|
|
|
|
morp = new IplImage(src.Size, BitDepth.U8, 1); |
|
|
|
|
bin = Binary(src, threshold); |
|
|
|
|
Cv.Erode(morp, morp, convKernel, iteration); |
|
|
|
|
Cv.Dilate(bin, morp, convKernel, iteration); |
|
|
|
|
|
|
|
|
|
return morp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
|
{ |
|
|
|
|
Release( |
|
|
|
@ -223,8 +264,15 @@ namespace OpenCV |
|
|
|
|
perspective, |
|
|
|
|
draw, |
|
|
|
|
hsv, |
|
|
|
|
hsvRed |
|
|
|
|
hsvRed, |
|
|
|
|
morp |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IplConvKernel ConvKernel |
|
|
|
|
{ |
|
|
|
|
get { return this.convKernel; } |
|
|
|
|
set { this.convKernel = value; } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|