Skip to content

Support for Grays wrapping signed FixedPointNumbers #42

@tlnagy

Description

@tlnagy

Currently ImageShow breaks when trying to display images with signed FixedPointNumbers, e.g. Q0f31, etc

julia> using TiffImages, ImageShow

julia> img = TiffImages.load("example.tif")
┌ Info: For better quality inline display of large images or thumbnails, load the Images package.
└ @ ImageShow /home/tlnagy/.julia/packages/ImageShow/11zF7/src/showmime.jl:131
┌ Info: Precompiling ImageMagick [6218d12a-5da1-5696-b52f-db25d2ecc6d1]
└ @ Base loading.jl:1317
┌ Warning: Mapping to the storage type failed; perhaps your data had out-of-range values?
│ Try `map(clamp01nan, img)` to clamp values to a valid range.
└ @ ImageMagick /home/tlnagy/.julia/packages/ImageMagick/b8swT/src/ImageMagick.jl:180
Errors encountered while save FileIO.Stream{FileIO.DataFormat{:PNG}, IOContext{Base64.Base64EncodePipe}, Nothing}(IOContext(Base64.Base64EncodePipe(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1), 
All errors:
===========================================
ArgumentError: FixedPointNumbers.Q0f31 is a 32-bit type representing 4294967296 values from -1.0 to 1.0; cannot represent 1
===========================================
ArgumentError: FixedPointNumbers.Q0f31 is a 32-bit type representing 4294967296 values from -1.0 to 1.0; cannot represent 1
===========================================
FileIO.MimeWriter writer error: neither save nor fileio_save is defined
  due to 
...

example.tif is from tlnagy/TiffImages.jl#56 (comment)

julia> eltype(img)
ColorTypes.Gray{FixedPointNumbers.Q0f31}

It would super nice to display these sorts of images properly, i.e. with one color for negative numbers and another for positive or even reinterpreted as normed FixedPointNumbers. The former is definitely preferable, but the current behavior isn't nice for the end user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions