public static HImage CropRectangle1(this HImage image, HRectangle1 rectangle1) { var croppedImage = image.CropRectangle1(rectangle1.Row1, rectangle1.Column1, rectangle1.Row2, rectangle1.Column2); return(croppedImage); }
public virtual HRegion Extract(HImage image) { if (RegionExtractor == null) { return(Domain); } var domainRect = Domain.GetSmallestRectangle1(); var domainCropImage = image.CropRectangle1(domainRect); var region = RegionExtractor.Extract(domainCropImage); var movedRegion = region.MoveRegion(domainRect.Row1, domainRect.Column1); return(movedRegion); }
private EdgeSearchingResult CropDomain(HImage image, EdgeSearchingDefinition definition) { var swSearchEdge = new NotifyStopwatch("SearchEdge: " + definition.Name); var esr = new EdgeSearchingResult { Definition = definition.DeepClone(), Name = definition.Name }; var rectImage = image.ChangeDomainForRoiRectangle(definition.Line, definition.ROIWidth); var rectDomain = rectImage.GetDomain(); var rectDomainRect1 = rectDomain.GetSmallestRectangle1(); var rectCroppedImage = rectImage.CropDomain(); if (definition.Domain_SaveCacheImageEnabled) { rectCroppedImage.WriteImageOfTiffLzw( _cacheImageDir + "\\SearchEdges_" + definition.Name + "_1_Domain_Cropped.tif"); } // RegionExtractor HRegion roiDomain; if (esr.Definition.RegionExtractor != null) { var croppedRoiDomain = esr.Definition.RegionExtractor.Extract(rectCroppedImage); roiDomain = croppedRoiDomain.MoveRegion(rectDomainRect1.Row1, rectDomainRect1.Column1); } else { roiDomain = rectDomain; } var roiDomainRect1 = roiDomain.GetSmallestRectangle1(); HImage roiCroppedImage = image.CropRectangle1(roiDomainRect1); // ImageFilter HImage filterImage = null; if (esr.Definition.ImageFilter != null) { var sw = new NotifyStopwatch("ImageFilter"); filterImage = esr.Definition.ImageFilter.Process(roiCroppedImage); sw.Dispose(); if (definition.ImageFilter_SaveCacheImageEnabled) { var cropDomain = filterImage.CropDomain(); cropDomain.WriteImageOfTiffLzw(_cacheImageDir + "\\SearchEdges_" + definition.Name + "_3_ImageFilter_Cropped.tif"); cropDomain.Dispose(); // var paintedImage = filterImage.PaintGrayOffset(image, offsetY, offsetX); // paintedImage.WriteImageOfJpeg(_cacheImageDir + "\\SearchEdges_" + definition.Name + // "_3_ImageFilter_PaintGrayOffset.jpg"); // paintedImage.Dispose(); } } else { filterImage = roiCroppedImage; } Line offsetLine = new Line(esr.Definition.Line.X1 - roiDomainRect1.Column1, esr.Definition.Line.Y1 - roiDomainRect1.Row1, esr.Definition.Line.X2 - roiDomainRect1.Column1, esr.Definition.Line.Y2 - roiDomainRect1.Row1); var line = esr.Definition.LineExtractor.FindLine(filterImage, offsetLine); var translatedLine = new Line(line.X1 + roiDomainRect1.Column1, line.Y1 + roiDomainRect1.Row1, line.X2 + roiDomainRect1.Column1, line.Y2 + roiDomainRect1.Row1); esr.EdgeLine = translatedLine; if (line.IsEmpty) { esr.IsNotFound = true; Debug.WriteLine("Edge not found: " + esr.Name); } swSearchEdge.Dispose(); return(esr); }