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

Display error on IJulia notebook #462

Closed
sunilnayak133 opened this issue Apr 3, 2016 · 3 comments
Closed

Display error on IJulia notebook #462

sunilnayak133 opened this issue Apr 3, 2016 · 3 comments
Labels
enhancement Adds a new feature. up for grabs

Comments

@sunilnayak133
Copy link

I was running the fft method on an image I loaded into the variable 'c', and it resulted in the error below.

l = fft(float64(c))
MethodError: `mapinfo` has no method matching mapinfo(::Type{FixedPointNumbers.UFixed{UInt8,8}}, ::Images.Image{Complex{Float64},3,Array{Complex{Float64},3}})
Closest candidates are:
  mapinfo(::Type{FixedPointNumbers.UFixed{UInt8,8}}, !Matched::Union{AbstractArray{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},N},AbstractArray{FixedPointNumbers.UFixed{UInt8,8},N}})
  mapinfo(::Type{FixedPointNumbers.UFixed{UInt8,8}}, !Matched::Union{AbstractArray{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt16,10}},N},AbstractArray{FixedPointNumbers.UFixed{UInt16,10},N}})
  mapinfo(::Type{FixedPointNumbers.UFixed{UInt8,8}}, !Matched::Union{AbstractArray{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt16,12}},N},AbstractArray{FixedPointNumbers.UFixed{UInt16,12},N}})
  ...

 in mapinfo_writemime at /Users/linus/.julia/v0.4/Images/src/writemime.jl:42
 in base64encode at base64.jl:160
 in display_dict at /Users/linus/.julia/v0.4/IJulia/src/execute_request.jl:32

This was run inside an IJulia Notebook, using the Julia 0.4.5 kernel.

cc: @rohitvarkey

@SimonDanisch
Copy link
Member

Well, as you can see, the result type of fft is Image{Complex}, which can't be viewed directly.
I'm not a 100% sure if this is the intended usage, but it seems to work:

using FileIO, Images
img = load("...")
absolute_part = colorim(abs(fft(float64(img)))) # abs is defined for image directly but doesn't return an Image?
imaginary_part = colorim(imag(fft(float64(img)).data)) # imag doesn't seem to be defined for Image directly?

@rohitvarkey
Copy link

Well, as you can see, the result type of fft is Image{Complex}, which can't be viewed directly.

Would it be a good idea to make these kind of images use a different writemime (maybe call writemime on the data?) rather than erroring out trying to display it?

Also I tried the abs.. way to display the fft but I get an InexactError().

@timholy
Copy link
Member

timholy commented Apr 6, 2016

If there's an obvious way to display it, then a custom writemime method would be fine. For example, for an fft of a grayscale image, I could imagine using one colorchannel for real and one for imaginary.

However, as soon as you think about an fft of an RGB image, there aren't enough color channels. So, for complex-valued images I recommend just using console-display (as with show). Since I don't use IJulia myself and have too many other commitments, this isn't a high priority of mine, so it will surely require a contribution from those for whom this matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds a new feature. up for grabs
Projects
None yet
Development

No branches or pull requests

6 participants