moving trinarize func

This commit is contained in:
tth
2021-03-26 05:40:45 +01:00
parent 2cf45fdbe5
commit 5d121dee87
4 changed files with 51 additions and 47 deletions

View File

@@ -45,3 +45,50 @@ for (foo=0; foo<size; foo++) {
return 0;
}
/* -------------------------------------------------------------- */
int fimg_trinarize(FloatImg *pimg, int notused)
{
float mm[6], mRa, mGa, mBa, mRb, mGb, mBb;
float *fptr;
int foo, size;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
#endif
foo = fimg_get_minmax_rgb(pimg, mm);
mRa = (mm[1] - mm[0]) * 0.33333;
mGa = (mm[3] - mm[2]) * 0.33333;
mBa = (mm[5] - mm[4]) * 0.33333;
mRb = (mm[1] - mm[0]) * 0.66666;
mGb = (mm[3] - mm[2]) * 0.66666;
mBb = (mm[5] - mm[4]) * 0.66666;
size = pimg->width * pimg->height;
for (foo=0; foo<size; foo++) {
fptr = pimg->R;
if (fptr[foo] < mRa || fptr[foo] > mRb)
fptr[foo] = mm[0];
else
fptr[foo] = mm[1];
fptr = pimg->G;
if (fptr[foo] < mGa || fptr[foo] > mGb)
fptr[foo] = mm[2];
else
fptr[foo] = mm[3];
fptr = pimg->B;
if (fptr[foo] < mBa || fptr[foo] > mBb)
fptr[foo] = mm[4];
else
fptr[foo] = mm[5];
}
return 0;
}
/* -------------------------------------------------------------- */