From b9cf14c20abb6361978c0baa838eee055fd493c7 Mon Sep 17 00:00:00 2001 From: b Date: Wed, 28 May 2014 13:10:38 +0000 Subject: [PATCH] ENHANCEment algorithm improved! git-svn-id: svn://botcastle1b/bluenh@3 276fc840-c973-4a23-809e-93696693fc29 --- bluenh.cpp | 84 +++++++++++++++++++++++++++++++++++------------------ bluenh.htm | 4 +-- bluenhd.cpp | 20 +++++++------ 3 files changed, 69 insertions(+), 39 deletions(-) diff --git a/bluenh.cpp b/bluenh.cpp index f2c15d4..13de6b6 100644 --- a/bluenh.cpp +++ b/bluenh.cpp @@ -20,6 +20,13 @@ #define CG newdata[4*(i+inX*j)+1] #define CB newdata[4*(i+inX*j)+2] +#define A ((long)(a)) +#define B ((long)(b)) +#define C ((long)(c)) +#define D ((long)(d)) +#define E ((long)(e)) +#define F ((long)(f)) + #include #include #include @@ -27,13 +34,13 @@ void mustard(int mustard); ILubyte enhance(ILubyte x, long r, long s, long t); ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f); +ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c); int main (int argc, const char *argv[]); ILuint pix; ILboolean q=true; ILboolean pixOpen=false; -ILuint inX, inY; -ILubyte *newdata; + ILubyte enhance(ILubyte x, long r, long s, long t) { @@ -43,12 +50,20 @@ ILubyte enhance(ILubyte x, long r, long s, long t) ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f) { - return (ILubyte)((x<=a)?d:((x>=c)?f:((x>b)?(enhance(x,f-e,c-b,e*c-b*f)):((x=c)?f:((x>b)?(enhance(x,F-E,C-B,E*C-B*F)):((x=CG) + if(CR==CG&&CG==CB) + continue; + //it'll stilll work correctly if two are equal. + if(CR>CG) { - if(CR>=CB) + if(CG>CB) + { + h=&(CR); + s=&(CG); + l=&(CB); + } + else if(CB>CR) { - if(CR>CG) - { - CR=enhance2(CR,a,b,c,d,e,f); - if(CR==CB) - CB=enhance2(CB,a,b,c,d,e,f); - } - else - { - if(CR>CB) - { - CR=enhance2(CR,a,b,c,d,e,f); - if(CR==CG) - CG=enhance2(CG,a,b,c,d,e,f); - } - } + h=&(CB); + s=&(CR); + l=&(CG); } else - CB=enhance2(CB,a,b,c,d,e,f); + { + h=&(CR); + s=&(CB); + l=&(CG); + } } else { - if(CG>=CB) + if(CR>CB) + { + h=&(CG); + s=&(CR); + l=&(CB); + } + else if(CB>CG) { - CG=enhance2(CG,a,b,c,d,e,f); - if(CG==CB) - CB=enhance2(CB,a,b,c,d,e,f); + h=&(CB); + s=&(CG); + l=&(CR); } else - CB=enhance2(CB,a,b,c,d,e,f); + { + h=&(CG); + s=&(CB); + l=&(CR); + } } + g=*h; + *h=enhance2(*h,a,b,c,d,e,f); + *s=enhance3(*s,*l,g,*h); } } if(!ilSave(IL_PNG,argv[2]))mustard(OUTPIX_MUSTARD); diff --git a/bluenh.htm b/bluenh.htm index 3997431..ef514af 100644 --- a/bluenh.htm +++ b/bluenh.htm @@ -3,7 +3,7 @@ ENHANCE! • Bicycles on the Moon - + 1190.bicyclesonthemoon.dnsd.info @@ -13,8 +13,8 @@
a=, b=, c=,
d=, e=, f=.
+ a < b < c

- Enhance by URL
URL of image: diff --git a/bluenhd.cpp b/bluenhd.cpp index 54ef528..130b3d8 100644 --- a/bluenhd.cpp +++ b/bluenhd.cpp @@ -19,6 +19,7 @@ #define WGET_PATH "/usr/bin/wget" #define ENH_PATH "./bluenh" +#define ENH_PATH2 "./bluenh2" #define RM_PATH "/bin/rm" #define LOG_PATH "/eizm/log/bluenh/bluenh.log" #define USERAGENT "Bluenhancement\x20(1190.bicyclesonthemoon.dnsd.info/bluenh/bluenh.htm)" @@ -28,22 +29,22 @@ int main (int argc, char *argv[]); void mustard(int mustard); FILE *pix; -unsigned char buf[1024]; + char url[1024]; char path[256]; -char method[256]; s_cgi *cgi; int t; pid_t sub; -struct stat st; -unsigned long p; -unsigned short q; -char **up; -// unsigned char a,b,c,d,e,f; -// bool meg=false; int main (int argc, char *argv[]) { + unsigned char buf[1024]; + struct stat st; + unsigned long p; + unsigned short q; + char **up; + bool enh2; + cgi=cgiInit(); up=cgiGetFiles(cgi); @@ -68,10 +69,11 @@ int main (int argc, char *argv[]) if(t)mustard(t); } + enh2=(cgiGetValue(cgi,"bluenh2")!=NULL); sub=fork(); if(sub==0) { - t=execl(ENH_PATH,ENH_PATH,path,path,cgiGetValue(cgi,"a")!=NULL?cgiGetValue(cgi,"a"):"0",cgiGetValue(cgi,"b")!=NULL?cgiGetValue(cgi,"b"):"127",cgiGetValue(cgi,"c")!=NULL?cgiGetValue(cgi,"c"):"255",cgiGetValue(cgi,"d")!=NULL?cgiGetValue(cgi,"d"):"0",cgiGetValue(cgi,"e")!=NULL?cgiGetValue(cgi,"e"):"127",cgiGetValue(cgi,"f")!=NULL?cgiGetValue(cgi,"f"):"255","q",(char *)0); + t=execl(enh2?ENH_PATH2:ENH_PATH,enh2?ENH_PATH2:ENH_PATH,path,path,cgiGetValue(cgi,"a")!=NULL?cgiGetValue(cgi,"a"):"0",cgiGetValue(cgi,"b")!=NULL?cgiGetValue(cgi,"b"):"127",cgiGetValue(cgi,"c")!=NULL?cgiGetValue(cgi,"c"):"255",cgiGetValue(cgi,"d")!=NULL?cgiGetValue(cgi,"d"):"0",cgiGetValue(cgi,"e")!=NULL?cgiGetValue(cgi,"e"):"127",cgiGetValue(cgi,"f")!=NULL?cgiGetValue(cgi,"f"):"255","q",(char *)0); exit(t); } waitpid(sub,&t,0); -- 2.30.2