JuliaImages / ImageSegmentation.jl

Partitioning images into meaningful regions
Other
47 stars 23 forks source link

Added URG algorithm #2

Closed annimesh2809 closed 7 years ago

annimesh2809 commented 7 years ago

An implementation of the unseeded region growing algorithm. The API is consistent with the SRG algorithm and output is also of type SegmentedImage. It supports N-dimensional arrays with arbitrary indices. Similar to SRG, it can take custom neighborhood as a Function as well as Union{Vector{Int}, NTuple{N, Int}}. Tests and docstring have been added.

Threshold Output Compression percentage
Original scene 0 %
0.02 seg1 50%
0.05 seg2 62.5%
0.1 seg3 70.8%
0.2 seg4 79.2%

The color of the ith segment corresponds to segment_means[i].

codecov[bot] commented 7 years ago

Codecov Report

Merging #2 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #2   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          95    150   +55     
=====================================
+ Hits           95    150   +55
Impacted Files Coverage Δ
src/region_growing.jl 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4233ca9...4e9bf68. Read the comment docs.

codecov[bot] commented 7 years ago

Codecov Report

Merging #2 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #2   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          95    155   +60     
=====================================
+ Hits           95    155   +60
Impacted Files Coverage Δ
src/region_growing.jl 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4233ca9...4e9bf68. Read the comment docs.

annimesh2809 commented 7 years ago

The performance has increased significantly after these changes. Here are some benchmarks on standard testimages.

julia> using TestImages, Images, BenchmarkTools, ImageSegmentation;

julia> img = testimage("camera");

julia> summary(img)
"512×512 Array{Gray{N0f8},2}"

julia> @benchmark unseeded_region_growing(img, 0.23, [5,5])
BenchmarkTools.Trial: 
  memory estimate:  13.21 MiB
  allocs estimate:  95
  --------------
  minimum time:     605.234 ms (0.00% GC)
  median time:      611.179 ms (0.24% GC)
  mean time:        622.737 ms (0.13% GC)
  maximum time:     674.381 ms (0.00% GC)
  --------------
  samples:          9
  evals/sample:     1

Output: seg

julia> img = testimage("house");

julia> summary(img)
"512×512 Array{GrayA{N0f8},2}"

julia> @benchmark unseeded_region_growing(img, 0.1)
BenchmarkTools.Trial: 
  memory estimate:  11.84 MiB
  allocs estimate:  86
  --------------
  minimum time:     457.768 ms (0.00% GC)
  median time:      468.675 ms (0.00% GC)
  mean time:        471.216 ms (0.06% GC)
  maximum time:     491.004 ms (0.12% GC)
  --------------
  samples:          11
  evals/sample:     1

Output: seg2

For smaller images, the algorithm takes only about 100ms.

I do not understand the terms memory estimate and allocs estimate clearly. Can you please explain.

timholy commented 7 years ago

Nice!

I do not understand the terms memory estimate and allocs estimate clearly. Can you please explain.

I think they mean "the amount of memory" and "the number of separate allocation events" respectively. If you allocate one big matrix, it might be a lot of memory but only one allocation event.

timholy commented 7 years ago

LGTM. Merge when ready.

timholy commented 7 years ago

:fireworks: