JuliaImages / ImageView.jl

Interactive display of images and movies
MIT License
135 stars 34 forks source link

Value range determined from whole volume, not first slice #261

Open felixhorger opened 2 years ago

felixhorger commented 2 years ago

Hi,

this is a useful tool, thanks for developing it! One minor improvement would be that the value range of grey scale volumes is computed over the whole volume instead of over the first slice.

Cheers, Felix

timholy commented 2 years ago

I agree this would improve some things, but I also worry about the case where the first volume might have ~1000 slices:

julia> using ImageView, BenchmarkTools

julia> a = rand(2048, 2048);

julia> @btime ImageView.default_clim($a)
  18.510 ms (2 allocations: 128 bytes)
Observable{CLim{Float64}} with 0 listeners. Value:
CLim{Float64}(3.144755991169035e-7, 0.9999997443110233)

Now multiply that by 1000 and you have 18s. Is it really worth that amount of time? Is there something else we could do instead?

felixhorger commented 2 years ago

Hi Tim, sorry for taking so long to get back to you! I wrote a function which is faster than minimum_finite/maximum_finite from Images.jl by a factor of nearly 5. On my machine the above test then takes only 4ms which would result in four seconds on the huge volume, that's alright I'd say. Another option would be to recompute the colour range for every slice upon selection, however in my experience that confuses the user (some MRI scanners do that -> flickering when scrolling). Let me know what you think. Cheers, Felix

timholy commented 1 year ago

I think we still might want to limit the number of points considered, e.g., if we've checked more than 10^8 points then I think we'd be safe. But otherwise I like this solution.

felixhorger commented 1 year ago

Done! :) What do you think about using threads to speed up the value span determination?