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

Images with IJulia and math #285

Closed
Jakki42 opened this issue Apr 20, 2015 · 4 comments
Closed

Images with IJulia and math #285

Jakki42 opened this issue Apr 20, 2015 · 4 comments

Comments

@Jakki42
Copy link

Jakki42 commented Apr 20, 2015

Hi again :) The 16-bit files display on IJulia now fine - thank you!

Still having trouble with IJulia & Images and FixedPointNumbers. (Julia 0.3.7, Windows 8.1, IPython/IJulia 3).

Gray Image with:
  data: 512x512 Array{Gray{UfixedBase{Uint16,16}},2}
  properties:
    IMcs: Gray
    spatialorder:  x y
    pixelspacing:  1 1

That displays properly.

A simple multiply by 10 makes it (as the FixedPointNumbers doc warns) different:

Gray Image with:
  data: 512x512 Array{Gray{Float64},2}
  properties:
    IMcs: Gray
    spatialorder:  x y
    pixelspacing:  1 1

And this no longer displays on IJulia, though it does on regular Julia - this is the error:

`mapinfo` has no method matching mapinfo(::Type{Gray{UfixedBase{Uint8,8}}}, ::Image{Gray{Float64},2,Array{Gray{Float64},2}})

 in base64 at base64.jl:125
 in display_dict at C:\Users\Jakki\.julia\v0.3\IJulia\src\execute_request.jl:31

I also wonder if there is a neat and simple way to use convert() to turn the Gray{Float64} array of an image into Fixed point array without possibly having to code a needlessly complex function to do it or even having to create a whole new image just to do this?

@elsuizo
Copy link

elsuizo commented Apr 21, 2015

Hi your problem is display a Gray image in IJulia?¿
you could silence the output and use PyPlot.imshow function . As follow:
gray_image_ijulia_2

@timholy
Copy link
Member

timholy commented Apr 22, 2015

@Jakki42, Image's map/MapInfo functionality is basically "convert on steroids": you specify the type of transformation you want to achieve with a small type, and then this transformation can be done lazily. I use it all the time when looking at images that are > 1TB in size, to ensure that conversions only happen on the tiny chunk I happen to be looking at.

In my limited Julia time, I'm busy with other things, trying to get some (for me) very challenging changes into julia before the 0.4 window closes (JuliaLang/julia#10911). If you want to try fixing this problem yourself, it's probably a few-line change: you basically need to provide a good default MapInfo object for the types involved. Hopefully the documentation, and the code in src/map.jl, should help.

@Jakki42
Copy link
Author

Jakki42 commented Apr 23, 2015

@timholy - I had a peek at the code and quickly noticed it's way beyond my skill level as a novice Julia programmer to do anything at all to the relevant code :( To make things even worse, it's hard for me to even figure out how to use Git and Julia in this context.

Here are a couple of related problems with tiff-files converted with 'dcraw -D -4 -T':

show(x)

Gray Image with:
  data: 6024x4024 Array{Gray{UfixedBase{Uint16,16}},2}
  properties:
    IMcs: Gray
    spatialorder:  x y
    pixelspacing:  1 1

x

`_map` has no method matching _map(::Type{UfixedBase{Uint8,8}}, ::Type{BS{8}}, ::Float64)

 in _map_a! at C:\Users\Jakki\.julia\v0.3\Images\src\map.jl:361
 in map! at C:\Users\Jakki\.julia\v0.3\Images\src\map.jl:353
 in image2wand at C:\Users\Jakki\.julia\v0.3\Images\src\io.jl:332
 in writemime at C:\Users\Jakki\.julia\v0.3\Images\src\io.jl:229
 in base64 at base64.jl:125
 in display_dict at C:\Users\Jakki\.julia\v0.3\IJulia\src\execute_request.jl:31

x*1.0

`mapinfo` has no method matching mapinfo(::Type{Gray{UfixedBase{Uint8,8}}}, ::Image{Gray{Float64},2,Array{Gray{Float64},2}})

 in base64 at base64.jl:125
 in display_dict at C:\Users\Jakki\.julia\v0.3\IJulia\src\execute_request.jl:31

the view() function luckily works fine in each case and I'll be using it regardless so the IJulia issues are secondary for me.

@elsuizo - thank you for the hint. I'll keep that in mind if I need to work around the problem(s).

@timholy
Copy link
Member

timholy commented May 20, 2015

OK, this is fixed (all except your x example in the post above, which is the same as #269---only happens on big images in IJulia). Also, worth mentioning that @cbecker contributed raw(img) which extracts the raw machine representation of the image data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants