Skip to content

extreme_filter: performance gap between UInt8 and Gray{N0f8} for diamond shape SE #103

@johnnychen94

Description

@johnnychen94

After #102:

img = float64.(imresize(testimage("cameraman"), (512, 512)));
@btime erode($img, $(strel_diamond(img)));

img_nf08 = n0f8.(imresize(testimage("cameraman"), (256, 256)));
@btime erode($img_nf08, $(strel_diamond(img_nf08)));
type size time (ms)
UInt8 (256, 256) 0.008
UInt8 (512, 512) 0.028
UInt8 (1024, 1024) 0.108
Float64 (256, 256) 0.047
Float64 (512, 512) 0.251
Float64 (1024, 1024) 1.450
type size time (ms)
Gray{N0f8} (256, 256) 0.014
Gray{N0f8} (512, 512) 0.036
Gray{N0f8} (1024, 1024) 0.118
Gray{Float64} (256, 256) 0.049
Gray{Float64} (512, 512) 0.247
Gray{Float64} (1024, 1024) 1.487

This is mainly because rawview(channelview(img_n0f8)) is a MappedArray and should be fixed somewhere upstream (ImageCore, probably)

julia> versioninfo()
Julia Version 1.9.0-DEV.843
Commit 4873773d37e (2022-06-23 18:35 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin21.5.0)
  CPU: 16 × Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.5 (ORCJIT, skylake)
  Threads: 8 on 8 virtual cores
Environment:
  JULIA_NUM_THREADS = 8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions