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

Gray image can not be displayed as an true image #588

Closed
Gnimuc opened this issue Nov 25, 2016 · 6 comments
Closed

Gray image can not be displayed as an true image #588

Gnimuc opened this issue Nov 25, 2016 · 6 comments

Comments

@Gnimuc
Copy link

Gnimuc commented Nov 25, 2016

Take a look at the following toy example:

using Plots, Images; #gr()
plot(grayim(rand(16,16)))

grayim

It seems that Plots considered the gray image as a common matrix. However, other image types can be displayed correctly. I guess this might due to the data structure of the gray image which is indeed a plain Matrix.

@tbreloff
Copy link
Member

Hmm this is tricky. The type from grayim is a subset of AbstractArray{Float64,2}... not the same as if you loaded it from a file. In order to define a recipe that would work, I'd have to add a dependency on Images (which I don't want). Another option would be to add the recipe to Images itself, which would require a dependency on RecipesBase (cc @timholy)

The current workaround is to explicitly map this to a matrix of colors:

using Plots, Images
img = convert(Matrix{Gray}, grayim(rand(16,16)))
plot(img)

tmp

@timholy
Copy link
Contributor

timholy commented Nov 28, 2016

In the "new Images" (see JuliaImages/Images.jl#542, especially JuliaImages/Images.jl#542 (comment)) it will return something of type Gray, so your intention will be clear.

@tbreloff
Copy link
Member

@timholy do you mean that with the new Images the convert will be unnecessary? (I.e. The grayim call will return a "matrix of Gray"?) If so, that's great... nothing to be done.

@timholy
Copy link
Contributor

timholy commented Nov 28, 2016

Well, grayim is going away, it will be called colorview(Gray, rand(16, 16)).

@timholy
Copy link
Contributor

timholy commented Nov 28, 2016

But yes, nothing you need to do here.

@tbreloff
Copy link
Member

Cool... gonna close this then. Thanks!

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