Exemplo n.º 1
0
        protected void LoadHDR(string fn, string param)
        {
            inputImage = origInputImage = RadianceHDRFormat.FromFile(fn);
            subFactor  = 1;
            contrast   = 0.0;
            if (inputImage == null)
            {
                return;
            }

            inputImage.Contrast(out minY, out maxY);
            if (minY > double.Epsilon)
            {
                minLog2  = Math.Log(minY) / Math.Log(2.0);
                maxLog2  = Math.Log(maxY) / Math.Log(2.0);
                contrast = maxLog2 - minLog2;

                // GUI update:
                labelMin.Text = string.Format(CultureInfo.InvariantCulture, "{0:f1} EV", minLog2);
                labelMax.Text = string.Format(CultureInfo.InvariantCulture, "{0:f1} EV", maxLog2);
                changeLabelExp();
            }

            Exposure(param);
        }
Exemplo n.º 2
0
        static public void Evaluate()
        {
            wasEvaluated = true;
            try
            {
                using (TextWriter wri = new StreamWriter(Path.Combine(EvalOptions.options.outDir, EvalOptions.options.outputFileName), false, Encoding.UTF8))
                {
                    string part;

                    // compile all source files:
                    if (!wasCompiled)
                    {
                        Options.Log(null);
                        CompileSources(EvalOptions.options.sourceFiles);
                        wasCompiled = true;
                    }
                    int images = EvalOptions.options.inputFiles.Count;
                    Console.WriteLine(Options.LogFormat("Configuration - assemblies: {0}, bans: {1}, best: {2}, images: {3}, output: '{4}'",
                                                        assemblies.Count, EvalOptions.options.bans.Count, EvalOptions.options.best.Count,
                                                        images, EvalOptions.options.outputFileName));

                    // HTML file header:
                    if (Util.ReadTextFile(EvalOptions.options.headerFile, out part))
                    {
                        wri.Write(part);
                    }

                    wri.WriteLine("<table class=\"nb\">");
                    wri.WriteLine("<tr><th>Name</th><th>Time</th><th>Image</th></tr>");

                    int ord = 0;
                    foreach (var imageFn in EvalOptions.options.inputFiles)
                    {
                        wri.WriteLine("<tr><td>&nbsp;</td></tr>");

                        string relative = EvalOptions.options.imageLocal ?
                                          Path.GetFileName(imageFn) :
                                          Util.MakeRelativePath(EvalOptions.options.outDir, imageFn);
                        string   relativeLDR = relative.Replace(".hdr", ".jpg");
                        string[] desctiption;
                        EvalOptions.options.imageInfo.TryGetValue(Path.GetFileName(imageFn), out desctiption);
                        wri.WriteLine("<tr><td colspan=\"2\" class=\"b p r\">{0}</td>",
                                      (desctiption == null) ? "&nbsp;" : string.Join(", ", desctiption));
                        wri.WriteLine($"<td><a href=\"{relative}\"><img src=\"{relativeLDR}\" width=\"{EvalOptions.options.imageWidth}\" alt=\"input\" /></a></td>");
                        wri.WriteLine("</tr>");

                        FloatImage image = RadianceHDRFormat.FromFile(imageFn);
                        Options.LogFormatMode("debug", "Input image '{0}':", imageFn);

                        qtime.Clear();

                        List <string> names = new List <string>(assemblies.Keys);
                        names.Sort();
                        string outBase = Path.Combine(EvalOptions.options.outDir, Path.GetFileNameWithoutExtension(imageFn));
                        foreach (var name in names)
                        {
                            if (!EvalOptions.options.bans.Contains(name) &&
                                (!EvalOptions.options.bestOnly || EvalOptions.options.best.Contains(name)))
                            {
                                EvaluateSolution(name, assemblies[name], image, outBase, wri);
                            }
                        }

                        wri.Write(string.Format(CultureInfo.InvariantCulture, "<tr><th class=\"l\">Time [s]</th><td class=\"p t r\">{0:f2}s</td>",
                                                qtime.Mean));
                        wri.WriteLine(string.Format(CultureInfo.InvariantCulture, "<td class=\"p\">+-{0:f2}s, quartiles: {1:f2} - {2:f2} - {3:f2} - {4:f2} - {5:f2}</td></tr>",
                                                    qtime.Variance, qtime.Min, qtime.Quartile(1), qtime.Median, qtime.Quartile(3), qtime.Max));

                        Console.WriteLine(Options.LogFormat("Finished image #{0}/{1} '{2}'", ++ord, images, relative));
                    }
                    wri.WriteLine("</table>");

                    // HTML file footer:
                    if (Util.ReadTextFile(EvalOptions.options.footerFile, out part))
                    {
                        wri.Write(part);
                    }
                }
            }
            catch (IOException e)
            {
                Console.WriteLine(Options.LogFormat("I/O error: {0}", e.Message));
            }
        }