public Analysis(List <Data.Point> points, IMathematical core3x3, IMathematical core5x5, IMathematical core7x7) { pointAnalysis = points; matematical3x3 = core3x3; matematical5x5 = core5x5; matematical7x7 = core7x7; gradients3x3 = new Dictionary <Point, List <double> >(); gradients5x5 = new Dictionary <Point, List <double> >(); gradients7x7 = new Dictionary <Point, List <double> >(); foreach (var point in pointAnalysis) { gradients3x3.Add(point, new List <double>()); gradients5x5.Add(point, new List <double>()); gradients7x7.Add(point, new List <double>()); } }
public Analysis(List <Data.Point> points) { pointAnalysis = points; matematical3x3 = new MathematicialSearchPoint1(); matematical5x5 = new MathematicialSearchPoint8(); matematical7x7 = new MathematicialSearchPoint9(); gradients3x3 = new Dictionary <Point, List <double> >(); gradients5x5 = new Dictionary <Point, List <double> >(); gradients7x7 = new Dictionary <Point, List <double> >(); foreach (var point in pointAnalysis) { gradients3x3.Add(point, new List <double>()); gradients5x5.Add(point, new List <double>()); gradients7x7.Add(point, new List <double>()); } }
public void clarifySolution(Data.Image image, List <IMathematical> coreGoodPoint, List <Data.Point> goodPoint) { if (swingSharpness == null) { swingSharpness = new double[image.width(), image.height()]; /* for (int x = 0; x < image.width(); x++) * for (int y = 0; y < image.height(); y++) * swingSharpness[x, y] = 0;*/ width = image.width(); height = image.height(); } List <Data.Point> listPoint = new List <Data.Point>(); Bitmap curentImage = image.image; curentImage = changeImage.translateToMonochrome(curentImage); HashSet <IMathematical> set = new HashSet <IMathematical>(coreGoodPoint); foreach (var i in set) { i.setImage(curentImage); } for (int i = 0; i < goodPoint.Count; i++) { int x = goodPoint[i].x; int y = goodPoint[i].y; matematical = set.First(item => item.GetType() == coreGoodPoint[i].GetType()); double gradient = matematical.gradientAtPoint(x, y); if (gradient > swingSharpness[x, y]) { listPoint.Add(new Data.Point(x, y)); swingSharpness[x, y] = gradient; } } solution.setValue(listPoint, image); }
public SparseElimination(IMathematical strategia) { changeImage = new ChangeImage(); matematical = strategia; swingSharpness = null; }
public SparseElimination() { changeImage = new ChangeImage(); matematical = new MathematicialSearchPoint13(); swingSharpness = null; }
static void Main(string[] args) { IParser parser = new Parser(); ICalculated calculated; IPreserveOBJ preserveOBJ = new PreserveOBJ(); IPreservePNG preservePNG = new PreservePNG(); IElimination elimination; IAnalysis analysis; Setting setting = null; INIManager manager; List <string> filesImagesname; string pathFolder; string pathConfig; string pathSetting; string saveFolder; if (args.Length == 0) { Console.WriteLine("usage: Get3DModel.exe <path to folder>"); Environment.Exit(-1); } pathFolder = args[0]; pathSetting = pathFolder + "\\setting.ini"; manager = new INIManager(pathSetting); string[] separators = { "\\" }; string[] words = pathFolder.Split(separators, StringSplitOptions.RemoveEmptyEntries); saveFolder = words[0]; for (int i = 1; i < words.Length - 1; i++) { saveFolder = saveFolder + "\\" + words[i]; } saveFolder = saveFolder + "\\Resulst_" + words[words.Length - 1]; Directory.CreateDirectory(saveFolder); StreamWriter timeTxt = new StreamWriter(saveFolder + "\\time.txt"); string[] listFileFolder = Directory.GetDirectories(pathFolder); foreach (string folder in listFileFolder) { FileInfo fileInfFolder = new FileInfo(folder); string nameFolder = fileInfFolder.Name; string saveFolderCurrent = saveFolder + "\\" + nameFolder; Directory.CreateDirectory(saveFolderCurrent); filesImagesname = Directory.GetFiles(folder, "*.png").ToList <string>(); pathConfig = Directory.GetFiles(folder).ToList().First( x => x.EndsWith(".camera") || x.EndsWith(".ini") || x.EndsWith("ConfigurationFile.txt")); FileInfo fileInf = new FileInfo(pathConfig); if (fileInf.Exists) { setting = new Setting(pathConfig); } else { Console.WriteLine("the configuration file is not found"); Environment.Exit(-1); } Stopwatch timeForParsing = new Stopwatch(); timeForParsing.Restart(); string nameCoreElimination = manager.GetPrivateString("ELIMINATION", "core"); IMathematical coreElimination = getMathematical(nameCoreElimination); if (coreElimination != null) { string thresholdElimination = manager.GetPrivateString("ELIMINATION", "threshold"); if (thresholdElimination != "default") { double deltaTheshold = Convert.ToDouble(thresholdElimination); coreElimination.setDeltaThreshold(deltaTheshold); } elimination = new Elimination(coreElimination); } else { elimination = new Elimination(); } for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); elimination.calculateGradientImage(itemImage); } List <Data.Point> goodPoint = elimination.getSolution(); string boolSelectionCore = manager.GetPrivateString("SELECTION_CORE", "selection_core"); if (boolSelectionCore == "true") { string nameCore3x3 = manager.GetPrivateString("CORE", "3_core"); IMathematical core3x3 = getMathematical(nameCore3x3); if (core3x3 == null) { core3x3 = new MathematicialSearchPoint1(); } string nameCore5x5 = manager.GetPrivateString("CORE", "5_core"); IMathematical core5x5 = getMathematical(nameCore5x5); if (core5x5 == null) { core5x5 = new MathematicialSearchPoint8(); } string nameCore7x7 = manager.GetPrivateString("CORE", "7_core"); IMathematical core7x7 = getMathematical(nameCore5x5); if (core7x7 == null) { core7x7 = new MathematicialSearchPoint9(); } analysis = new Analysis(goodPoint, core3x3, core5x5, core7x7); for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); analysis.addImageAnalysis(itemImage); } List <IMathematical> coreGoodPoint = analysis.getCore(); calculated = new Calculated(); calculated.createdBeginSolution(); for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); calculated.clarifySolution(itemImage, coreGoodPoint, goodPoint); } } else { string nameCore = manager.GetPrivateString("SELECTION_CORE", "default_core"); IMathematical core = getMathematical(nameCore); if (core == null) { core = new MathematicialSearchPoint1(); } calculated = new Calculated(core); calculated.createdBeginSolution(); for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); calculated.clarifySolution(itemImage, goodPoint); } } Solution solution = calculated.getSolution(); timeForParsing.Stop(); timeTxt.WriteLine(nameFolder + " - " + timeForParsing.ElapsedMilliseconds + " timeForParsing"); preserveOBJ.saveOBJ(solution, setting, saveFolderCurrent); preservePNG.savePNG(solution, saveFolderCurrent); saveDat(solution.Map, saveFolderCurrent); } timeTxt.Close(); }
public Calculated(IMathematical stategia) { changeImage = new ChangeImage(); matematical = stategia; }
//double thresholdDelta; public Calculated() { changeImage = new ChangeImage(); matematical = new MathematicalDefault(); }
public MathematicalController(CalculatorDbContext dbContext, ILogger <MathematicalController> logger, IMathematical mathematical) { _dbContext = dbContext; _logger = logger; _mathematical = mathematical; }