+ hipass filter

This commit is contained in:
Tonton Th 2020-12-19 10:19:18 +01:00
parent 152bb72522
commit 22ef7c084e

View File

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