JuliaImages / JuliaImages/ImageView.jl

Display custom type with PNG support

Open
#307 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
138
Forks
33
PR merge metrics
No merged PRs in 30d

Description

How can I use imshow to display an image of my custom type which has support for the image/png MIME type via Base.show?

Is it not supported, or is imshow not the appropriate function for this? Or does ImageView support some kind of AbstractDisplay, so that I could write display(ImageViewDisplay, Foo())?

Minimum non-working example:

julia> using ImageView, PNGFiles, TestImages

julia> struct Foo end

julia> Base.show(io::IO, ::MIME"image/png", x::Foo) = PNGFiles.save(io, testimage("mandrill"))

julia> imshow(Foo())
ERROR: MethodError: no method matching size(::Foo)

Closest candidates are:
  size(::Core.Compiler.StmtRange)
   @ Base show.jl:2774
  size(::Base.ExceptionStack)
   @ Base errorshow.jl:1018
  size(::Base.AsyncGenerator)
   @ Base asyncmap.jl:389
  ...

Stacktrace:
 [1] axes(A::Foo)
   @ Base .\abstractarray.jl:98
 [2] roi(A::Foo, dims::Tuple{Int64, Int64})
   @ ImageView C:\Users\jwortmann\.julia\packages\ImageView\Gg1GW\src\slicing.jl:45
 [3] imshow(img::Any; axes::Any, name::Any, aspect::Any)
   @ ImageView C:\Users\jwortmann\.julia\packages\ImageView\Gg1GW\src\ImageView.jl:277
 [4] imshow(img::Any)
   @ ImageView C:\Users\jwortmann\.julia\packages\ImageView\Gg1GW\src\ImageView.jl:274
 [5] top-level scope
   @ REPL[13]:1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the imshow entry point in src/ImageView.jl around line 274 and the roi logic in src/slicing.jl around line 45. Reproduce the Foo() example and determine the display contract for custom image/png values, including whether an AbstractDisplay path is relevant. Done should be a tested or documented resolution for the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.