Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ImageView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function imshow(frame::Union{Gtk4.GtkFrame,Gtk4.GtkAspectFrame}, canvas::GtkObse
# such errors become easier to debug.
if !supported_eltype(imgc[])
!supported_eltype(imgsig[]) && error("got unsupported eltype $(eltype(imgsig[])) in creating slice")
error("got unsupported eltype $(eltype(imgc[])) in preparing the constrast")
error("got unsupported eltype $(eltype(imgc[])) in preparing the contrast")
end

roidict = imshow(frame, canvas, imgc, zr, anns)
Expand Down Expand Up @@ -564,6 +564,12 @@ function _deflt_clim(img::AbstractMatrix)
Observable(CLim(saferound(gray(minval)), saferound(gray(maxval))))
end

# The method above began throwing an error for integers >1 in mid 2025
# This restores the previous "clamping" behavior
function _deflt_clim(img::AbstractMatrix{T}) where {T<:Integer}
Observable(CLim(0.0, 1.0))
end

function _deflt_clim(img::AbstractMatrix{T}) where {T<:AbstractRGB}
minval = RGB(0.0,0.0,0.0)
maxval = RGB(1.0,1.0,1.0)
Expand All @@ -584,7 +590,11 @@ default_axes(img::AxisArray) = axisnames(img)[[1,2]]

function histsignals(enabled::Observable{Bool}, img::Observable, clim::Observable{CLim{T}}) where {T<:GrayLike}
image, cl = img[], clim[]
Th = float(promote_type(T, eltype(image)))
hist_type = promote_type(T, eltype(image))
if hist_type == Any
error("got unsupported eltype Any in preparing the contrast")
end
Th = float(hist_type)
function computehist(image, cl)
smin, smax = valuespan(image)
smin = float(min(smin, cl.min))
Expand Down
2 changes: 1 addition & 1 deletion test/newtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ end
img = [OneChannelColor(0) OneChannelColor(1);
OneChannelColor(2) OneChannelColor(3);
]
@test_throws ErrorException("got unsupported eltype Union{} in preparing the constrast") imshow(img, CLim(0, 1))
@test_throws ErrorException("got unsupported eltype Any in preparing the contrast") imshow(img, CLim(0, 1))

struct MyChar <: AbstractChar
c::Char
Expand Down
Loading