Skip to content

Commit

Permalink
Update compare.rb for imageflow_tool (draft)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Sep 25, 2020
1 parent 73702f3 commit dce7eb9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
1 change: 1 addition & 0 deletions imageflow_tool/result_testing/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/scope/*.png
/imagew
/rscope
/scope
/flow-proto1
/source_images/

Expand Down
2 changes: 1 addition & 1 deletion imageflow_tool/result_testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Open ./compare/index.html in your browser when complete.
## Updating Imageflow results

1. Run `./compare_reset_flow_images.sh` to invalidate all imageflow-generated results.
2. delete flow-proto1
2. delete imageflow_tool
3. Run `./install_tools.sh`
4. Run `./compare.rb`
42 changes: 29 additions & 13 deletions imageflow_tool/result_testing/compare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
IMAGES = ["turtleegglarge.jpg","rings2.png","gamma_dalai_lama_gray.jpg","u1.jpg","waterhouse.jpg","u6.jpg","premult_test.png","gamma_test.jpg"]


version_info = `convert --version` + `./flow-proto1 --version` + `./imagew --version`
version_info = `convert --version` + `./imageflow_tool --version` + `./imagew --version`

`./fetch_images.sh`

`mkdir ./compare/images`
`mkdir -p ./compare/images`
EXEPATH = "./"
IMAGEPATH = "./source_images/"
OUTPATH ="./compare/images/"
Expand All @@ -24,15 +24,21 @@ def create_command(tool, image, nogamma, filter, sharpen, w)
if filter == :robidoux
w_filter = " -filter cubic0.37821575509399867,0.31089212245300067 "
end
if filter == :robidouxsharp
if filter == :robidoux_sharp
w_filter=" -filter cubic0.2620145123990142,0.3689927438004929 "
end
if filter == :ncubic
if filter == :n_cubic
w_filter=" -filter cubic0.37821575509399867,0.31089212245300067 -blur 0.85574108326"
end
if filter == :ncubicsharp
if filter == :n_cubic_sharp
w_filter=" -filter cubic0.2620145123990142,0.3689927438004929 -blur 0.90430390753 "
end
if filter == :catmull_rom
w_filter = " -filter catrom "
end
if filter == :cubic_b_spline
w_filter = " -filter bspline "
end
if filter == :ginseng
return nil #Because imagew doesn't do ginseng
end
Expand All @@ -44,15 +50,21 @@ def create_command(tool, image, nogamma, filter, sharpen, w)
if filter == :ginseng
magick_filter = " -define filter:filter=Sinc -define filter:window=Jinc -define filter:lobes=3 "
end
if filter == :ncubic
magick_filter = " -filter robidoux -define filter:blur=0.85574108326 "
if filter == :n_cubic
magick_filter = " -filter robidoux -define filter:blur=0.85574108326 "
end
if filter == :bspline
magick_filter = " -filter spline"
if filter == :cubic_b_spline
magick_filter = " -filter spline"
end
if filter == :ncubicsharp
if filter == :n_cubic_sharp
magick_filter = " -filter robidouxsharp -define filter:blur=0.90430390753 "
end
if filter == :catmull_rom
magick_filter = " -filter catrom "
end
if filter == :robidoux_sharp
magick_filter = " -filter robidouxsharp "
end
if nogamma
command = "convert #{infile} #{magick_filter} -resize #{w} #{OUTPATH}#{outfile}"
else
Expand All @@ -61,7 +73,7 @@ def create_command(tool, image, nogamma, filter, sharpen, w)
end
if tool == :flow
outputformat = image =~ /\.png/ ? "png" : "png24"
command = "#{EXEPATH}flow-proto1 #{nogamma ? '--incorrectgamma' : ''} --down-filter #{filter} --up-filter #{filter} --format #{outputformat} -m 100 --constrain distort --sharpen #{sharpen} -w #{w} -i #{infile} -o #{OUTPATH}#{outfile}"
command = "#{EXEPATH}imageflow_tool v1/querystring --command=\"&f.sharpen=#{sharpen}&w=#{w}&down.filter=#{filter}#{nogamma ? '&down.colorspace=srgb&up.colorspace=srgb' : ''}&decoder.min_precise_scaling_ratio=100&up.filter=#{filter}&format=#{outputformat}&scale=both\" --in #{infile} --out #{OUTPATH}#{outfile} --quiet"
end
{command: command, image: image, gamma: nogamma ? 'nogamma' : 'linear', filter: filter, sharpen: sharpen,
w: w, tool: tool,
Expand All @@ -70,8 +82,10 @@ def create_command(tool, image, nogamma, filter, sharpen, w)

# imageflow's box filter acts differently, and is not compared here
SIZES = [200,400,800]
FILTERS = [:triangle, :lanczos, :lanczos2, :ginseng, :ncubic, :ncubicsharp, :robidoux, :robidouxsharp,
:bspline, :hermite, :catrom, :mitchell]


FILTERS = [:triangle, :lanczos, :lanczos2, :ginseng, :n_cubic, :n_cubic_sharp, :robidoux, :robidoux_sharp,
:cubic_b_spline, :hermite, :catmull_rom, :mitchell]
GAMMAS = [true, false]
SHARPENS = [0,2,5,10]

Expand Down Expand Up @@ -162,3 +176,5 @@ def generate_for(tool)

IO.write("./compare/data.js", "window.data = " + JSON.pretty_generate(json_hash) + ";")

puts "\n Open ./compare/compare.html in your browser.\n"
puts "open ./compare/compare.html || x-www-browser ./compare/compare.html "

0 comments on commit dce7eb9

Please sign in to comment.