Extract Lightness - RealWorld forums

Log-in or register.

Extract Lightness

PAEz
on October 29th 2013

Extract Lightness
Deletes any pixel that doesnt fall within a certain range.
Its another thing you can use to get a glow/bloom effect.
Duplicate a layer, run this on it, then blur it.
Or on an image that doesn't have much white highlights, this is cool....
Duplicate the layer,run this with default range and Render as greyscale set to true, blur by around 15, change the blend mode of the layer to add (mess with that, its fun), change opacity to suit. If you've got windows7 look in My Pictures/Sample Pictures and try it on the Chrysanthemum.jpg...nice ;-)
Sometimes it can really help to use the Effect/Outline to draw a white outline on the glow layer before blurring it.

Code
Configuration

Configuration.AddEditBox("lightnessMinimum", "Minimum", "", 0.55);
Configuration.AddEditBox("lightnessMaximum", "Maximum", "", 1);
Configuration.AddCheckBox("lightOnly", "Render as lightness greyscale", "")

Execution

var minL = Configuration.lightnessMinimum;
var maxL = Configuration.lightnessMaximum;
var lightOnly = Configuration.lightOnly;

var image = Document.RasterImage;
var w = image.sizeX;
var h = image.sizeY;

var cL,x,y;

for (x=0; x<w; x++){
for (y=0; y<h; y++){

cL = image.GetPixelL(x, y, 0, 0);

if (cL>maxL || cL<minL) {
image.setPixel(x, y, 0, 0, 0);
} else if (lightOnly) {
image.setPixelHLS(x, y, 0, 0, 0, cL, 0);
}

}
}
Page views: 791       Posts: 1      
I wish there were...
Vista & Win 7 icons
What about ICL files?