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

Plotting an image without white borders #211

Open
maajkus opened this issue Apr 17, 2015 · 5 comments
Open

Plotting an image without white borders #211

maajkus opened this issue Apr 17, 2015 · 5 comments

Comments

@maajkus
Copy link

maajkus commented Apr 17, 2015

Hello

Is there a way to plot an image without axes labels and blank area around it (using imagesc)?

Regards
Mike

@timholy
Copy link
Member

timholy commented Apr 17, 2015

If you just want the raw image itself (no axes), you can use ImageView's write_to_png.

@maajkus
Copy link
Author

maajkus commented Apr 17, 2015

write_to_png(imagesc(rand(300,400)),"file.png") gives an error :
write_to_png has no method matching write_to_png(::FramedPlot, ::ASCIIString)

Could you help me out?

@timholy
Copy link
Member

timholy commented Apr 17, 2015

You have to use ImageView to plot the image, too. See https://github.com/timholy/ImageView.jl#programmatic-usage

imgc, _ = view(img)
write_to_png(imgc, filename)

@maajkus
Copy link
Author

maajkus commented Apr 18, 2015

Can't figure this out, i have a matrix 256x320 with temperature values from 20 - 50 celsius and when i run the code below it pops up empty window, I can adjust the contrast slider , but it gives me image in a grayscale, and i need a RGB image.

k=vars["p15"]["Frame90"]    #Matrix Float64 256x320
zimg=convert(Image,k)
img,_=ImageView.view(zimg)

@timholy
Copy link
Member

timholy commented Apr 19, 2015

Currently there isn't a function like imagesc, but you can write it in a few lines using ImageCmap, something along the lines of

mn,mx = extrema(img)
lookup = round(Int, length(cmap)*(img-mn)/(mx-mn)
ImageCmap(lookup, cmap)

where cmap is a vector of ColorType. (Not tested.)

The better way would be to create a custom MapInfo object, because that wouldn't allocate any unnecessary memory.

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

2 participants