Welcome to ClientVPS Mirrors

Treating Color Image with imagerExtra

Treating Color Image with imagerExtra

Shota Ochi

2019-01-25

We have two options when treating color images with imagerExtra.

The former is straightforward.

One example is shown below.

library(imagerExtra)
x <- boats
s <- 0.1
R(x) <- BalanceSimplest(R(x), s, s, range=c(0,1))
G(x) <- BalanceSimplest(G(x), s, s, range=c(0,1))
B(x) <- BalanceSimplest(B(x), s, s, range=c(0,1))
layout(matrix(1:2, 1, 2))
plot(boats, main = "Original")
plot(x, main = "Independently Processed")

The latter needs three functions: Grayscale, GetHue, RestoreHue.

grayscale function of imager computes as shown below by default.

Y = 0.300000R + 0.590000G + 0.110000B

where Y is grayscale value, R is R value, G is G value, and B is B value.

This equation reflects the way of human visual perception.

This grayscale conversion makes it difficult to restore hue of image.

That’s why we need Grayscale function, which just compute average of RGB channels.

How to use these functions is shown below.

g <- Grayscale(boats)
hueim <- GetHue(boats)
g <- BalanceSimplest(g, s, s, range=c(0,1))
y <- RestoreHue(g, hueim)
layout(matrix(1:2, 1, 2))
plot(boats, main = "Original")
plot(y, main = "Processed While Preserving Hue")

Which way is better?

It’s your call.

You should consider which way is better when treating color images.

Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.

This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.