mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-15 12:20:03 +01:00
add gamma and alpha parameters to black white by threshold
rename black white by threshold to black white mask by threshold
This commit is contained in:
@@ -26,46 +26,130 @@
|
||||
vj_effect *bwselect_init(int w, int h)
|
||||
{
|
||||
vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect));
|
||||
ve->num_params = 2;
|
||||
ve->num_params = 4;
|
||||
ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */
|
||||
ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */
|
||||
ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */
|
||||
ve->defaults[0] = 16;
|
||||
ve->defaults[1] = 235;
|
||||
ve->parallel = 1;
|
||||
ve->defaults[2] = 400;
|
||||
ve->defaults[3] = 0;
|
||||
|
||||
ve->limits[0][0] = 0;
|
||||
ve->limits[1][0] = 255;
|
||||
ve->limits[0][1] = 0;
|
||||
|
||||
ve->limits[0][1] = 0;
|
||||
ve->limits[1][1] = 255;
|
||||
|
||||
ve->description = "Black and White by Threshold";
|
||||
ve->sub_format = -1;
|
||||
ve->limits[0][2] = 0;
|
||||
ve->limits[1][2] = 1000;
|
||||
|
||||
ve->limits[0][3] = 0;
|
||||
ve->limits[1][3] = 1;
|
||||
|
||||
ve->description = "Black and White Mask by Threshold";
|
||||
|
||||
ve->sub_format = -1;
|
||||
ve->extra_frame = 0;
|
||||
ve->has_user =0 ;
|
||||
ve->param_description = vje_build_param_list( ve->num_params, "Min threshold", "Max threshold" );
|
||||
ve->has_user =0;
|
||||
ve->parallel = 1;
|
||||
|
||||
ve->param_description = vje_build_param_list( ve->num_params, "Min Threshold", "Max Threshold", "Gamma", "Alpha" );
|
||||
return ve;
|
||||
}
|
||||
|
||||
void bwselect_apply(VJFrame *frame, int width, int height, int min_threshold, int max_threshold) {
|
||||
static int last_gamma = 0;
|
||||
static uint8_t table[256];
|
||||
|
||||
static void gamma_setup(int width, int height, double gamma_value)
|
||||
{
|
||||
int i;
|
||||
double val;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
val = i / 256.0;
|
||||
val = pow(val, gamma_value);
|
||||
val = 256.0 * val;
|
||||
table[i] = val;
|
||||
}
|
||||
}
|
||||
|
||||
void bwselect_apply(VJFrame *frame, int width, int height, int min_threshold, int max_threshold, int gamma, int mode) {
|
||||
int r,c;
|
||||
const int len = frame->len;
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *Cb = frame->data[1];
|
||||
uint8_t *Cr = frame->data[2];
|
||||
|
||||
for(r=0; r < len; r+=width) {
|
||||
for(c=0; c < width; c++) {
|
||||
uint8_t p = Y[r+c];
|
||||
if( p > min_threshold && p < max_threshold) {
|
||||
Y[r+c] = pixel_Y_hi_;
|
||||
if( gamma == 0 )
|
||||
{
|
||||
if( mode == 0 ) {
|
||||
for(r=0; r < len; r+=width) {
|
||||
for(c=0; c < width; c++) {
|
||||
uint8_t p = Y[r+c];
|
||||
if( p > min_threshold && p < max_threshold) {
|
||||
Y[r+c] = pixel_Y_hi_;
|
||||
}
|
||||
else {
|
||||
Y[r+c] = pixel_Y_lo_;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Y[r+c] = pixel_Y_lo_;
|
||||
veejay_memset(Cb, 128, (frame->ssm ? frame->len : frame->uv_len));
|
||||
veejay_memset(Cr, 128, (frame->ssm ? frame->len : frame->uv_len));
|
||||
}
|
||||
else {
|
||||
uint8_t *aA = frame->data[3];
|
||||
for(r=0; r < len; r+=width) {
|
||||
for(c=0; c < width; c++) {
|
||||
uint8_t p = Y[r+c];
|
||||
if( p > min_threshold && p < max_threshold) {
|
||||
aA[r+c] = 0xff;
|
||||
}
|
||||
else {
|
||||
aA[r+c] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( gamma != last_gamma ) {
|
||||
gamma_setup( width,height,(double) gamma / 100.0 );
|
||||
last_gamma = gamma;
|
||||
}
|
||||
|
||||
if( mode == 0 ) {
|
||||
for(r=0; r < len; r+=width) {
|
||||
for(c=0; c < width; c++) {
|
||||
uint8_t p = table[ Y[r+c] ];
|
||||
if( p > min_threshold && p < max_threshold) {
|
||||
Y[r+c] = pixel_Y_hi_;
|
||||
}
|
||||
else {
|
||||
Y[r+c] = pixel_Y_lo_;
|
||||
}
|
||||
}
|
||||
}
|
||||
veejay_memset(Cb, 128, (frame->ssm ? frame->len : frame->uv_len));
|
||||
veejay_memset(Cr, 128, (frame->ssm ? frame->len : frame->uv_len));
|
||||
}
|
||||
else {
|
||||
uint8_t *aA = frame->data[3];
|
||||
for(r=0; r < len; r+=width) {
|
||||
for(c=0; c < width; c++) {
|
||||
uint8_t p = table[ Y[r+c] ];
|
||||
if( p > min_threshold && p < max_threshold) {
|
||||
aA[r+c] = 0xff;
|
||||
}
|
||||
else {
|
||||
aA[r+c] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
veejay_memset(Cb, 128, (frame->ssm ? frame->len : frame->uv_len));
|
||||
veejay_memset(Cr, 128, (frame->ssm ? frame->len : frame->uv_len));
|
||||
}
|
||||
|
||||
void bwselect_free(){}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
vj_effect *bwselect_init();
|
||||
void bwselect_apply(VJFrame *frame, int width, int height, int min_threshold,
|
||||
int max_threshold);
|
||||
void bwselect_apply(VJFrame *frame, int width, int height, int min_threshold,int max_threshold, int mode, int gamma);
|
||||
void bwselect_free();
|
||||
#endif
|
||||
|
||||
@@ -448,7 +448,7 @@ extern void greyselect_apply(VJFrame *frame, int w, int h, int angle, int r, int
|
||||
extern void isolate_apply(VJFrame *frame, int w, int h, int angle, int r, int g, int b,
|
||||
int opacity);
|
||||
|
||||
extern void bwselect_apply(VJFrame *frame, int w, int h, int a , int b);
|
||||
extern void bwselect_apply(VJFrame *frame, int w, int h, int a , int b, int c, int g);
|
||||
|
||||
extern void complexinvert_apply(VJFrame *frame, int w, int h, int angle, int r, int g, int b, int i_noise);
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ void vj_effman_apply_image_effect(
|
||||
arg[0]);
|
||||
break;
|
||||
case VJ_IMAGE_EFFECT_BWSELECT:
|
||||
bwselect_apply(frames[0], frames[0]->width, frames[0]->height, arg[0], arg[1]);
|
||||
bwselect_apply(frames[0], frames[0]->width, frames[0]->height, arg[0], arg[1], arg[2], arg[3]);
|
||||
break;
|
||||
case VJ_IMAGE_EFFECT_GREYSELECT:
|
||||
greyselect_apply(frames[0], frames[0]->width, frames[0]->height,arg[0],arg[1],arg[2],arg[3],arg[4]);
|
||||
|
||||
Reference in New Issue
Block a user