BeautifulMakie icon indicating copy to clipboard operation
BeautifulMakie copied to clipboard

Request: Image histogram

Open cormullion opened this issue 2 years ago • 1 comments

I couldn't find a nice easy image histogram easily, so I wonder if it might be a nice addition to your beautiful collection?

I struggled to make this:

using CairoMakie
using StatsBase
using Images
using TestImages

function  image_histogram()
    img = testimage("lighthouse")
    fig = Figure(); ax = Axis(fig[1, 1])
    reds = vec(float.(red.(img)))
    greens = vec(float.(green.(img)))
    blues = vec(float.(blue.(img)))

    for (i, col) = enumerate([:red, :green, :blue])
        hist!(ax, (reds, greens, blues)[i], scale_to=-0.6, bins=60, offset=i, direction=:x, color=col)
    end
    fig
end 

fig = with_theme(image_histogram, theme_black())
Screenshot 2021-10-11 at 16 42 20

I think a better version of this could be useful. People ask for it on stack overflow and discourse...

cormullion avatar Oct 11 '21 15:10 cormullion

Thanks for the issue. I didn't see the issues (probably I'm not that active anymore :(, other duties). But, I did a bunch of different options for histogram here. Either way, I will add a nice version also in the gallery. Nowadays, I don't know what is missing, so please, if there are requests out there feel free to open more issues, I will try to add them as soon as I'm able to do so.

lazarusA avatar Oct 11 '21 18:10 lazarusA

this example now live here

lazarusA avatar Sep 12 '22 14:09 lazarusA