Tuesday, March 24, 2015

Luminosity masks for demons, Homogeneity via Euclidean-based metrics for God-fearing demoniacs

Pixel-perfect image processing is the only suitable goal for a demoniac hell-bent on delivering to the common man a viable, useful and readily accessible tool for standing up to demon tyranny, and whether he is fighting for his life (or his eyesight) and the lives of those he loves [see The Last Battle of a Dead Man] is not the only reason. Here are the others:

First, delivering any product less than the best is detestable to God:
A false balance is an abomination to the LORD, but a just weight is his delight.
(Proverbs 11:1)
Second, delivering any product less than the best is not of God, and is therefore a wasted effort:
Unless the LORD builds the house, those who build it labor in vain. Unless the LORD watches over the city, the watchman stays awake in vain.
(Psalms 127:1)
Third, delivering the best quality product creates opportunities not otherwise available to your typical desperate and destitute demoniac:
Do you see a man skillful in his work? He will stand before kings; he will not stand before obscure men.

(Proverbs 22:29)
Fourth, it is a way of serving God in a situation in which this is otherwise impossible...
Whatever you do, work heartily, as for the Lord and not for men, knowing that from the Lord you will receive the inheritance as your reward. You are serving the Lord Christ.
(Colossians 3:23-24)
...which you can do when doing work beneficial to all...

With good will doing service, as to the Lord, and not to men.
(Ephesians 6:7)

...which you should do with anything you do at all, even things that are considered common:

Whether therefore ye eat, or drink, or whatsoever ye do, do all to the glory of God.
(1 Corinthians 10:31)

Having said all that, I then say away with luminosity masks, and in with homogeneity via Euclidean-based metrics, at least when it comes to isolating problematic regions in an image and applying localized corrections to them.

Masking and correcting problematic regions in an image: killing two birds with one stone
Perhaps the reason why the demoniac in The Exorcist (1973) had so much trouble with her demons is because girls suck at math (or, so they say); but, for the demon-plagued willing to delve into the world of vector calculus and the like, life should be a little rosier than Regan's.

Most graphics artists and photography use masks to isolate and apply corrections and enhancements to specific regions in an image based on pixel luminosity, which requires a visual inspection of shadows and highlights to determine what to change, how to change it, and by how much. Then, there's whether to change anything at all.

The problem is that's at least four decisions to be made based on someone's arbitrary and subjective and visual assessment, which is not only fraught with error, but is not feasible for real-time video or a collection of thousands of images. Not only that, but most of the techniques that are applied via luminosity masks don't work with images shot under the conditions in which demonic activity video is recorded, as they do not correct combinations of imperfections, such as under-exposed darks and over-exposed brights (unbalanced luminance).
NOTE | Many types of corrections must be made in tandem with others, and at a certain ratio; and, sometimes, adjustments must be made to non-problematics regions of an image, just to accommodate corrections made to the problematic regions.
Real-time deviated-region identification and correction
Fortunately, computational vision and medical image processing technology has a solution that not only finds problematic regions of an image, but properly balances the corrections made to those regions to the image overall.

With just one calculation to find the standard deviation of each pixel value from the image's mean—specifically, via a Euclidean-based metric to determine the homogeneity of an image—the imperfect regions of an image can be isolated by subtracting the deviate pixel values from the original:

Subtracting an image derived from the standard deviation of the mean pixel values from the source image highlights portions of an image that are likely the problematic in contrast and/or brightness
In the example above, a balance in brightness was struck between the dark greens and bright yellows (and contrast greatly increased in the bright yellows) by subtracting the difference from the alpha channel of the source image. Compare the contrast and brightness-balance between the corrected and source image:

No overbright yellows, with tons of little details not see in the original in the flower petals; plus, the greens seem brighter by comparison, even though they are approximately the same, bringing balance to the image overallThe original might be beautiful, but look closely at the altered version, and you'll see details you could not otherwise; this is all-important in demonic-activity image processing
The OpenGLSL code:

kernel vec4 coreImageKernel(sampler image, float mean_r, float mean_g, float mean_b)
{
vec4 pixel = sample(image, samplerCoord(image));

// Formula:
// Subtract the mean of each color component from the source color component
// Square each result
// Add the squared results
// Find the square root of the sum
// Divide each color component of the source pixel by the result (standard deviation)

float sd = sqrt(pow((pixel.r - mean_r), 2.0) + pow((pixel.g - mean_g), 2.0) + pow((pixel.b - mean_b), 2.0));

return vec4(vec3(pixel.rgb), pixel.a - vec4(vec3(pixel.rgb - vec3(sd)), pixel.a));
}

By the way, sd stands for standard deviation, a number with which you can do a lot; and, there are almost as many ways to calculate it. Here's the formula I used:

A formula for calculating the standard deviation of pixel values from the mean of pixel values in an image; the higher the deviation, the more visible the pixels are in the resulting image
Look for more applications of the standard deviation to image-processing and correction in this post in the future.

Murder, Satan wrote | “They popped a cork on you…”

"Rock him off" and "Cash him in" are both phrases used to describe murder, or at least acts likely to lead to death, in ...