Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add play and explore for 3D and framestack image playback/interaction #43

Closed

Conversation

IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Feb 27, 2021

I thought these methods would make more sense in here than in https://github.com/IanButterworth/VideoInTerminal.jl given they require no further deps, and feel like an extension of current ImageInTerminal offerings.

using ImageInTerminal, TestImages
img3D = testimage("mri-stack")
explore(img3D, 3) # explore along dimension 3
play(img3D, 3) # play along dimension 3 (like explore but start playing, and exit when done)

explore_mri

using ImageInTerminal, ImageCore
framestack = map(_->rand(Gray{N0f8}, 100, 100), 1:200)
play(framestack, fps = 24) # play framestack back at a target of 24 fps
explore(framestack, fps = 24) # like play, but start paused

The methods that depend on VideoIO could stay in VideoInTerminal (like the webcam viewer.. which I recommend trying out!)

pkg> add https://github.com/IanButterworth/VideoInTerminal.jl 
julia> using VideoInTerminal
julia> showcam()

It's so awesome how well this works ImageInTerminal. The frame rates are really impressive. Nice work!

@johnnychen94
Copy link
Member

Thanks for proposing the new functionalities. I just come back from vacation; will try this out and fix the test tomorrow night.

@johnnychen94 johnnychen94 self-requested a review February 27, 2021 18:29
@johnnychen94 johnnychen94 self-assigned this Feb 27, 2021
src/multipage.jl Outdated Show resolved Hide resolved
src/multipage.jl Outdated Show resolved Hide resolved
function play(io::IO, arr::T, dim::Int; fps::Real=30, maxsize::Tuple = displaysize(io), paused = false) where {T<:AbstractArray}
@assert dim <= ndims(arr) "Requested dimension $dim, but source array only has $(ndims(arr)) dimensions"
@assert ndims(arr) <= 3 "Source array dimensions cannot exceed 3"
firstframe = T <: Vector ? first(selectdim(arr, dim, 1)) : selectdim(arr, dim, 1)
Copy link
Member

@johnnychen94 johnnychen94 Mar 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little bit dirty here to put the framestack support here. Indeed, a better strategy IMO is to put a lazy-view to convert Vector{<:AbstractArray{T, 2}} to Array{T, 3}.

- play(io::IO, framestack::Vector{T}; kwargs...) where {T<:AbstractArray} = play(io, framestack, 1; kwargs...)
+ play(io::IO, framestack::Vector{T}; kwargs...) where {T<:AbstractArray} = play(io, 3dview(framestack), 3; kwargs...)

Do you know if there's such a 3dview tool in Julia? Or I can make one for this.

@IanButterworth
Copy link
Member Author

@johnnychen94 just checking in on this. I believe your plan was to extend it to ImageShow first?

@johnnychen94
Copy link
Member

johnnychen94 commented Apr 10, 2021

Yes, I feel it a little bit hard to maintain by mixing both terminal display and keyboard IO control. So I want to put the keyboard IO control part to ImageShow, and then extend the terminal display feature here. That said, ImageInTerminal will depend on ImageShow in the future.

I'm recently started to finish my pending PRs, and this is on my to-do list.

So I want to put the keyboard IO control part to ImageShow

Ideally, we need an independent package (maybe KeyboardEvents.jl) for this, but I'm a little bit reluctant to have more packages given my limited time here...

@t-bltg
Copy link
Collaborator

t-bltg commented Aug 8, 2022

Superseded by JuliaImages/ImageShow.jl#29.

@t-bltg t-bltg closed this Aug 8, 2022
@IanButterworth IanButterworth deleted the ib/multipage branch August 8, 2022 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants