+ hipass filter

This commit is contained in:
tonton th 2020-12-19 10:19:18 +01:00
parent 152bb72522
commit 22ef7c084e
1 changed files with 49 additions and 4 deletions

View File

@ -49,12 +49,13 @@ fimg_destroy(&img);
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
static int insitu_filtre3x3(FloatImg *pimg) static int insitu_filtre3x3(FloatImg *pimg, int typef)
{ {
FloatImg img; FloatImg img;
int retval; int retval;
FimgFilter3x3 *pfiltre;
FimgFilter3x3 filtre = { FimgFilter3x3 lowpass = {
{ {
1.0, 2.0, 1.0, 1.0, 2.0, 1.0,
2.0, 4.0, 2.0, 2.0, 4.0, 2.0,
@ -63,8 +64,29 @@ FimgFilter3x3 filtre = {
16.0, 0.0 16.0, 0.0
}; };
FimgFilter3x3 hipass = {
{
-1.0, -1.0, -1.0,
-1.0, 9.0, -1.0,
-1.0, -1.0, -1.0,
},
1.0, 0.0
};
switch (typef) {
case 0: pfiltre = &lowpass; break;
case 1: pfiltre = &hipass; break;
default:
fprintf(stderr, "%s: bad filter number %d\n",
__func__, typef);
return -6;
break;
}
fimg_clone(pimg, &img, 0); fimg_clone(pimg, &img, 0);
retval = fimg_filter_3x3(pimg, &img, &filtre);
retval = fimg_filter_3x3(pimg, &img, pfiltre);
if (retval) { if (retval) {
fprintf(stderr, "%s error %d on filter\n", __func__, retval); fprintf(stderr, "%s error %d on filter\n", __func__, retval);
exit(1); exit(1);
@ -168,7 +190,7 @@ switch (idFx) {
(void)fimg_killborders(image); (void)fimg_killborders(image);
break; break;
case 13: case 13:
retval = insitu_filtre3x3(image); retval = insitu_filtre3x3(image, 0);
break; break;
case 14: case 14:
retval = desaturate(image); retval = desaturate(image);
@ -186,6 +208,9 @@ switch (idFx) {
case 18: case 18:
retval = upside_down(image); retval = upside_down(image);
break; break;
case 19:
retval = insitu_filtre3x3(image, 1);
break;
/* here are the glitches */ /* here are the glitches */
case 24: /* experiment ! */ case 24: /* experiment ! */
@ -213,13 +238,33 @@ count++;
return retval; return retval;
} }
/* -------------------------------------------------------------- */
typedef struct {
int id;
char *name;
int ipar;
float fpar;
int flags;
} Crapulor;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
char * crap_name_from_number(int num) char * crap_name_from_number(int num)
{ {
switch (num) { switch (num) {
case 0: return "none"; case 0: return "none";
case 1: return "cos01";
case 2: return "cos010";
case 6: return "killcola";
case 7: return "colmixa";
case 8: return "ctr2x2"; case 8: return "ctr2x2";
case 9: return "classif0";
case 10: return "binariz";
case 11: return "trinariz";
case 13: return "fltr3x3"; case 13: return "fltr3x3";
case 14: return "desatur";
case 18: return "updown"; case 18: return "updown";
} }