Here's how you can install the imhistR
package.
- Install the
remotes
package.
install.packages('remotes')
- Install the
datautils
package:
remotes::install_github("holgerbrandl/datautils", dependencies=TRUE)
- Install the (removed from CRAN)
patchPlot
package:
remotes::install_url('https://cran.r-project.org/src/contrib/Archive/patchPlot/patchPlot_0.1.5.tar.gz', dependencies = TRUE)
- Install the (removed from CRAN)
imhistR
package:
remotes::install_github("mokazuma/imhistR", dependencies=TRUE)
- Test the
imhistR
package:
require("imhistR")
lrgbhist(input, mode = "file", output = input, hist = TRUE,
resize = FALSE, endoff = FALSE, textsize = 16)
On my system, this yields:
trying URL 'https://www.r-project.org/Rlogo.png'
Content type 'image/png' length 32553 bytes (31 KB)
downloaded 31 KB
Mean_Luminance SD_Luminance Skew_Luminance
Rlogo.png 0.5307022 0.1816393 0.1654525
Kurt_Luminance Mean_Red SD_Red Skew_Red
Rlogo.png -1.697913 0.42456 0.2849509 0.01362389
Kurt_Red Mean_Green SD_Green Skew_Green
Rlogo.png -1.875264 0.552168 0.1613232 0.2315529
Kurt_Green Mean_Blue SD_Blue Skew_Blue
Rlogo.png -1.657691 0.7183205 0.05884395 -1.220589
Kurt_Blue
Rlogo.png 2.128444
Warning messages:
1: The dot-dot notation (`..x..`) was deprecated in ggplot2
3.4.0.
ℹ Please use `after_stat(x)` instead.
ℹ The deprecated feature was likely used in the imhistR
package.
Please report the issue at
<https://github.com/mokazuma/imhistR/issues>.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where
this warning was generated.
2: Removed 2 rows containing missing values (`geom_bar()`).
3: Removed 2 rows containing missing values (`geom_bar()`).
4: Removed 2 rows containing missing values (`geom_bar()`).
5: Removed 2 rows containing missing values (`geom_bar()`).
and the plot:

As you can see, the package needs some TLC, but it seems to work for now.
Edit:
Looking at the package code (https://github.com/mokazuma/imhistR/blob/13319682f0ca0750f9c7e36b5c98c4a68b2e632b/R/lrgbhist.R#L122),
the important bits seem to be these:
fn = "FILE_NAME_HERE.png"
img <- readbitmap::read.bitmap(fn)
red <- img[,,1]; green <- img[,,2]; blue <- img[,,3]
luminance <- .298912 * red + .586611 * green + .114478 * blue
mean(luminance)
If you install the readbitmap
package and if you're happy with the default settings in the imhistR::lrgbhist()
function, this code will give you what you want.