-
Notifications
You must be signed in to change notification settings - Fork 143
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
Add some missing convert(Array, img)
methods
#208
Comments
Grid is unnecessarily picky about its inputs; Grid is by this point a pretty old package, and a rewrite is slowly underway (https://github.com/tlycken/Interpolations.jl). Your best workaround is something like this: You shouldn't have to convert back to an Image to see the result; viewing should work just fine on plain arrays, modulo changes in orientation, etc. |
Thanks for suggesting that workaround, I think that should do it for me. It results in a transpose, but that's not a big deal. |
It doesn't actually transpose any data; the issue is that ImageView can handle images in either "row major" or "column major" format, but it requires the Image container to know what to do. Most/all image formats store data in "row major" format, and the rule in Images is "don't do anything you don't have to do," so it does not automatically take the transpose for you. You can alternatively say As a reminder to myself, I'm going to reopen this because I noticed that Images is missing some |
convert(Array, img)
methods
Since this thread's title suggests the
Is this the correct behavior? Also, what would be the idiomatic way to just get a 2D array of floats from a grayscale image loaded with I have julia 0.3.1 and these are my packages: julia> Pkg.status()
11 required packages:
- ArrayViews 0.4.6
- Cairo 0.2.20
- Distributions 0.5.4
- Gadfly 0.3.9
- HDF5 0.4.5
- IJulia 0.1.15
- ImageView 0.1.7
- Images 0.4.21
- Iterators 0.1.7
- PyPlot 1.4.0
- TestImages 0.0.6
37 additional packages:
- BinDeps 0.3.6
- Codecs 0.1.2
- Color 0.3.10
- Compat 0.1.0
- Compose 0.3.9
- Contour 0.0.5
- DataArrays 0.2.4
- DataFrames 0.5.11
- DataStructures 0.3.4
- Dates 0.3.2
- Distances 0.1.1
- FixedPointNumbers 0.0.4
- GZip 0.2.13
- Hexagons 0.0.2
- ImmutableArrays 0.0.6
- IniFile 0.2.3
- JSON 0.3.8
- KernelDensity 0.0.2
- LaTeXStrings 0.1.0
- Loess 0.0.3
- Nettle 0.1.6
- PDMats 0.2.4
- PyCall 0.4.10
- REPLCompletions 0.0.3
- Reexport 0.0.2
- SHA 0.0.3
- SIUnits 0.0.2
- Showoff 0.0.2
- SortingAlgorithms 0.0.2
- StatsBase 0.6.8
- TexExtensions 0.0.2
- Tk 0.2.15
- URIParser 0.0.3
- Winston 0.11.5
- ZMQ 0.1.14
- ZipFile 0.2.2
- Zlib 0.1.7 |
Similar issue: when I use
|
Sorry for the delay; I've been away without internet for several days. This is probably a julia bug, maybe related to #8631 (I know it doesn't look like it, but it just seems that julia> using Images, TestImages
julia> img = testimage("mandrill")
RGB Image with:
data: 512x512 Array{RGB{UfixedBase{Uint8,8}},2}
properties:
IMcs: sRGB
spatialorder: x y
pixelspacing: 1 1
julia> A = convert(Array, img)
ERROR: `convert` has no method matching convert(::Type{Array{T,N}}, ::Image{RGB{UfixedBase{Uint8,8}},2,Array{RGB{UfixedBase{Uint8,8}},2}})
in convert at base.jl:13
julia> @which convert(Array, img)
convert(::Type{Array{T,N}},img::AbstractImage{T,N}) at /home/tim/.julia/v0.3/Images/src/core.jl:227 I inserted some |
See JuliaLang/julia#8818, in case it's new behavior. |
Just in case, this works: convert(Array, data(img)) |
This was fixed by Color 0.3.12 (JuliaAttic/Color.jl@e880cbf). |
I am new to Images.jl, so there is definitely extensive functionality that I don't understand yet. Is there an easy way to interpolate a pixel value in an image, such as using Grid? I am looking to apply a homography to an image, and would like to do so as cleanly as possible.
Here is rough pseudocode of what I would like to do:
Where
NewEmptyImage
is some function that just creates an empty image of a prespecified size, and we can just assume that I know how to computei
andj
for my purposes.I'm trying to convert some code from Matlab, and in Matlab I just used generic arrays to store my images. That's another option for me here, but it seems like it would require a little more overhead any time I wanted to view or save an image. For my purposes, I only need 2D grayscale images, and was able to interpolate on that by converting it to an array of Float64's, but then I still need to convert it back into an image to see the result.
The text was updated successfully, but these errors were encountered: