divide blend issue

Here everybody can post his problems with PhotoLine
pculverhouse
Mitglied
Beiträge: 2
Registriert: Di 27 Apr 2021 12:31

divide blend issue

Beitrag von pculverhouse »

Hi,

I have discovered that the divide blend function allows me to correct for optical unevenness of my illumination source in images I take of marine plankton underwater.

I checked and found that the function is:

Resulting Color = 256 ÷ (Color of Layer with Divide Blend Mode ÷ Color of Layer Underneath)

I've converted by 8-bit RGB pixels into standarised luminance units, then implemented the divide blend.

Here I run through each of the 3 BGR values in the inner loop of row/column processing:

double pix = intensity.val[k]/255.0;
double backgndpix = bgnd.val[k]/255.0;
Iout.at<Vec3b>(j, i)[k] =static_cast<unsigned char>(256.0/(pix/backgndpix));

But the result is not as white blown-out as Photoline shows.

Any ideas what silly thing I am doing wrong?

regards

Phil
Martin Huber
Entwickler
Entwickler
Beiträge: 4159
Registriert: Di 19 Nov 2002 15:49

Re: divide blend issue

Beitrag von Martin Huber »

With pixel values in the [0;1] range, divide is simply

background: pixel value of background
foreground: pixel value of layer with blend mode "Divide"

result = 1;
if (background != 0)
result = foreground / background

With 8-bit pixel values, you have to multiply the result with 255
result8Bit = (foreground8Bit * 255) / background8Bit;

Martin
pculverhouse
Mitglied
Beiträge: 2
Registriert: Di 27 Apr 2021 12:31

Re: divide blend issue

Beitrag von pculverhouse »

Thanks Martin & Gerhardt,

Actually there is a slight change.

pixOUT = 255;
if (backgndpix != 0)
pixOUT = ((pixIN*256 / backgndpix));

works. The *255 caused me a small headache for a while.

But much appreciated.

Phil