JuliaImages / ImageView.jl

Interactive display of images and movies
MIT License
136 stars 32 forks source link

Set contrast programmatically for imshow? #228

Closed sremedios closed 4 years ago

sremedios commented 4 years ago

Is it possible to set the contrast programmatically for imshow? If so, it is possible to include examples in the docs?

I want to open three plots of an MRI image, each with a different view of the volume, and set the contrast to be the same for each of them.

johnnychen94 commented 4 years ago

I don't know if there's such a way in ImageView.jl, but you could try ImageConstrastAdjustment.jl and set contrast before visualization.

sremedios commented 4 years ago

I might try that out! Does that contrast adjustment change the underlying image intensity values? I would like to be able to mouse-over and see the intensities but have the visualization of the contrast change. imshow() does this currently, but I need to right-click to change the contrast each time.

timholy commented 4 years ago
using ImageView, TestImages
img = testimage("camera")
imshow(img, CLim(0,20))
sremedios commented 4 years ago

This works for me; however, when I try this function it fails:

using ImageView, Images
using GtkReactive
using Gtk

function triplanar_view(vol)
    vmax = Float32(maximum(vol))
    vmin = Float32(minimum(vol))

    imshow(vol, CLim(vmin, vmax); axes=(1, 2))
    imshow(vol, CLim(vmin, vmax); axes=(3, 1), flipy=true)
    imshow(vol, CLim(vmin, vmax); axes=(3, 2), flipy=true)
end
using TestImages
mri = testimage("mri")
triplanar_view(mri)

ERROR:

julia> triplanar_view(mri)
ERROR: MethodError: no method matching imshow(::AxisArray{Gray{Normed{UInt8,8}},3,Array{Gray{Normed{UInt8,8}},3},Tuple{Axis{:P,StepRange{Int64,Int64}},Axis{:R,StepRange{Int64,Int64}},Axis{:S,StepRange{Int64,Int64}}}}, ::CLim{Float32}; axes=(3, 1), flipy=true)
Closest candidates are:
  imshow(::AbstractArray, ::Any; axes, name, aspect) at C:\Users\Sam\.julia\packages\ImageView\L3gil\src\ImageView.jl:191 got unsupported keyword argument "flipy"
  imshow(::AbstractArray, ::Any, ::Signal{ZoomRegion{T}}, ::ImageView.SliceData) where T at C:\Users\Sam\.julia\packages\ImageView\L3gil\src\ImageView.jl:197 got unsupported keyword arguments "axes", "flipy"
  imshow(::AbstractArray, ::Any, ::Signal{ZoomRegion{T}}, ::ImageView.SliceData, ::Any; name, aspect) where T 
at C:\Users\Sam\.julia\packages\ImageView\L3gil\src\ImageView.jl:197 got unsupported keyword arguments "axes", "flipy"
  ...
Stacktrace:
 [1] kwerr(::NamedTuple{(:axes, :flipy),Tuple{Tuple{Int64,Int64},Bool}}, ::Function, ::AxisArray{Gray{Normed{UInt8,8}},3,Array{Gray{Normed{UInt8,8}},3},Tuple{Axis{:P,StepRange{Int64,Int64}},Axis{:R,StepRange{Int64,Int64}},Axis{:S,StepRange{Int64,Int64}}}}, ::CLim{Float32}) at .\error.jl:157
 [2] triplanar_view(::AxisArray{Gray{Normed{UInt8,8}},3,Array{Gray{Normed{UInt8,8}},3},Tuple{Axis{:P,StepRange{Int64,Int64}},Axis{:R,StepRange{Int64,Int64}},Axis{:S,StepRange{Int64,Int64}}}}) at C:\Users\Sam\Desktop\utils\plot.jl:10
 [3] top-level scope at none:1
timholy commented 4 years ago

Missing kwhandler. Want to submit a fix?

sremedios commented 4 years ago

Thanks, PR at #229

timholy commented 4 years ago

Fixed by #229