From 321fabcdf891a19c1d1a4cec6532f9b7bd8422cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Thu, 23 Sep 2021 02:54:15 +0100 Subject: v2.23.1 - **Issues:** - (Add) Suction cups: Additional setting to specify the required minimum height to be flagged as a issue (#302) - (Change) Allow touching bounds to have a bounding rectangle and zoom into the issue - (Change) Disable the ability to copy issues row text from list as this is crashing the program - (Change) Decrease cache count of the layers from x10 to x5 to free RAM - (Fix) Touching bounds are reporting areas of 0 - (Fix) Draw crosshair for issues are called multiple times - (Fix) Detection error when resin traps are enabled on some cases (#303) - (Fix) Resin trap false-positives (#305) - (Fix) When removing multiple islands at once only the first is cleared from the issue list - **UI:** - (Change) Tool - Resize icon - (Change) Move "Crosshairs" button inside "Issues" button - (Add) Tool - Morph - Offset crop: Like erode but discards the outer pixels - (Fix) Corrected bottom lift unit label in light-off delay calculator (#304) --- CHANGELOG.md | 20 +++++++++++++++++++- UVtools.Core/EmguCV/EmguContours.cs | 2 +- UVtools.Core/Extensions/EmguExtensions.cs | 14 ++++---------- UVtools.Core/Managers/IssueManager.cs | 2 +- UVtools.Core/Operations/OperationMorph.cs | 22 +++++++++++++++++----- UVtools.WPF/MainWindow.axaml | 27 ++++++++++++++++++++------- UVtools.WPF/MainWindow.axaml.cs | 2 +- 7 files changed, 63 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c031c11..3650bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,26 @@ # Changelog +## 23/09/2021 - v2.23.1 + +- **Issues:** + - (Add) Suction cups: Additional setting to specify the required minimum height to be flagged as a issue (#302) + - (Change) Allow touching bounds to have a bounding rectangle and zoom into the issue + - (Change) Disable the ability to copy issues row text from list as this is crashing the program + - (Change) Decrease cache count of the layers from x10 to x5 to free RAM + - (Fix) Touching bounds are reporting areas of 0 + - (Fix) Draw crosshair for issues are called multiple times + - (Fix) Detection error when resin traps are enabled on some cases (#303) + - (Fix) Resin trap false-positives (#305) + - (Fix) When removing multiple islands at once only the first is cleared from the issue list +- **UI:** + - (Change) Tool - Resize icon + - (Change) Move "Crosshairs" button inside "Issues" button +- (Add) Tool - Morph - Offset crop: Like erode but discards the outer pixels +- (Fix) Corrected bottom lift unit label in light-off delay calculator (#304) + ## 21/09/2021 - v2.23.0 -- Issues: +- **Issues:** - **Suction cups:** - Add a auto repair feature for this issues by drill a vertical vent hole (#296) - Add a manual repair feature for this issues by drill a vertical vent hole when click on remove (#301) diff --git a/UVtools.Core/EmguCV/EmguContours.cs b/UVtools.Core/EmguCV/EmguContours.cs index 62bfd47..50e37a4 100644 --- a/UVtools.Core/EmguCV/EmguContours.cs +++ b/UVtools.Core/EmguCV/EmguContours.cs @@ -241,7 +241,7 @@ namespace UVtools.Core.EmguCV CvInvoke.BitwiseAnd(contour1Mat, contour2Mat, contour1Mat); - return contour1Mat.FindFirstPositivePixel() != -1; + return !contour1Mat.IsZeroed(); } } } diff --git a/UVtools.Core/Extensions/EmguExtensions.cs b/UVtools.Core/Extensions/EmguExtensions.cs index 90473c4..1e85659 100644 --- a/UVtools.Core/Extensions/EmguExtensions.cs +++ b/UVtools.Core/Extensions/EmguExtensions.cs @@ -515,15 +515,9 @@ namespace UVtools.Core.Extensions /// /// Pixel brightness threshold /// - public static unsafe bool IsZeroed(this Mat mat, byte threshold = 0) + public static bool IsZeroed(this Mat mat, byte threshold = 0) { - var ptr = mat.GetBytePointer(); - var length = mat.GetLength(); - for (var i = 0; i < length; i++) - { - if (ptr[i] > threshold) return false; - } - return true; + return mat.FindFirstPixelGreaterThan(threshold) == -1; } #endregion @@ -546,7 +540,7 @@ namespace UVtools.Core.Extensions /// Pixel position in the span, or -1 if not found public static int FindFirstPositivePixel(this Mat mat) { - return mat.FindFirstPixelEqualOrGreaterThan(1); + return mat.FindFirstPixelGreaterThan(0); } /// @@ -1117,7 +1111,7 @@ namespace UVtools.Core.Extensions // if there are no more 'white' pixels in the image, then // break from the loop - if (image.FindFirstPixelEqualOrGreaterThan(1) == -1) break; + if (image.IsZeroed()) break; } return skeleton; diff --git a/UVtools.Core/Managers/IssueManager.cs b/UVtools.Core/Managers/IssueManager.cs index 6eb6874..a8109ee 100644 --- a/UVtools.Core/Managers/IssueManager.cs +++ b/UVtools.Core/Managers/IssueManager.cs @@ -1115,7 +1115,7 @@ namespace UVtools.Core.Managers CvInvoke.Circle(circleCheck, new(centroid.X + inverseOffset.X, centroid.Y + inverseOffset.Y), diameter, EmguExtensions.WhiteColor, -1); CvInvoke.BitwiseAnd(circleCheck, contourMat, circleCheck); - return circleCheck.FindFirstPositivePixel() != -1 + return !circleCheck.IsZeroed() ? centroid /* 5px centroid is inside layer! drill baby drill */ : new Point(-1,-1); /* centroid is not inside the actual contour, no drill */ } diff --git a/UVtools.Core/Operations/OperationMorph.cs b/UVtools.Core/Operations/OperationMorph.cs index 27fc4ef..ce73490 100644 --- a/UVtools.Core/Operations/OperationMorph.cs +++ b/UVtools.Core/Operations/OperationMorph.cs @@ -31,14 +31,17 @@ namespace UVtools.Core.Operations [Description("Dilate: Expands the boundaries within the object")] Dilate = MorphOp.Dilate, - [Description("Gap Closing - Closes small holes inside the objects")] + [Description("Gap closing: Closes small holes inside the objects")] Close = MorphOp.Close, - [Description("Noise Removal - Removes small isolated pixels")] + [Description("Noise removal: Removes small isolated pixels")] Open = MorphOp.Open, - [Description("Gradient - Removes the interior areas of objects")] + [Description("Gradient: Removes the interior areas of objects")] Gradient = MorphOp.Gradient, + + [Description("Offset crop: Like erode but discards the outer pixels")] + OffsetCrop, } #endregion @@ -66,6 +69,9 @@ namespace UVtools.Core.Operations #endregion #region Properties + + public MorphOp MorphOperationOpenCV => _morphOperation == MorphOperations.OffsetCrop ? MorphOp.Erode : (MorphOp)_morphOperation; + public MorphOperations MorphOperation { get => _morphOperation; @@ -186,13 +192,19 @@ namespace UVtools.Core.Operations if (CoreSettings.CanUseCuda) { var gpuMat = target.ToGpuMat(); - using var morph = new CudaMorphologyFilter((MorphOp)MorphOperation, target.Depth, target.NumberOfChannels, Kernel.Matrix, Kernel.Anchor, iterations); + using var morph = new CudaMorphologyFilter(MorphOperationOpenCV, target.Depth, target.NumberOfChannels, Kernel.Matrix, Kernel.Anchor, iterations); morph.Apply(gpuMat, gpuMat); gpuMat.Download(target); } else { - CvInvoke.MorphologyEx(target, target, (MorphOp) MorphOperation, Kernel.Matrix, Kernel.Anchor, iterations, BorderType.Reflect101, default); + CvInvoke.MorphologyEx(target, target, MorphOperationOpenCV, Kernel.Matrix, Kernel.Anchor, iterations, BorderType.Reflect101, default); + + if (_morphOperation == MorphOperations.OffsetCrop) + { + var originalRoi = GetRoiOrDefault(original); + originalRoi.CopyTo(target, target); + } } ApplyMask(original, target); diff --git a/UVtools.WPF/MainWindow.axaml b/UVtools.WPF/MainWindow.axaml index fc3559e..e825817 100644 --- a/UVtools.WPF/MainWindow.axaml +++ b/UVtools.WPF/MainWindow.axaml @@ -1868,25 +1868,38 @@ IsChecked="{Binding ShowLayerImageIssues}" ToolTip.Tip="Highlight Issues on current layer. Valid only if Issues are calculated." VerticalAlignment="Stretch" - Margin="1,0,0,0" - > - + Margin="1,0,0,0"> + + + + + + + + + + + + - + +