Winston.jl icon indicating copy to clipboard operation
Winston.jl copied to clipboard

Plotting an image without white borders

Open maajkus opened this issue 10 years ago • 5 comments

Hello

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

Regards Mike

maajkus avatar Apr 17 '15 11:04 maajkus

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

timholy avatar Apr 17 '15 12:04 timholy

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?

maajkus avatar Apr 17 '15 13:04 maajkus

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)

timholy avatar Apr 17 '15 13:04 timholy

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)

maajkus avatar Apr 18 '15 10:04 maajkus

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.

timholy avatar Apr 19 '15 11:04 timholy