]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
ENHANCEment algorithm improved!
authorb <b@276fc840-c973-4a23-809e-93696693fc29>
Wed, 28 May 2014 13:10:38 +0000 (13:10 +0000)
committerb <b@276fc840-c973-4a23-809e-93696693fc29>
Wed, 28 May 2014 13:10:38 +0000 (13:10 +0000)
git-svn-id: svn://botcastle1b/bluenh@3 276fc840-c973-4a23-809e-93696693fc29

bluenh.cpp
bluenh.htm
bluenhd.cpp

index f2c15d47f6615db388ed506a7d523163e2d8110b..13de6b6a80b5aec590fbee230afc382920f38add 100644 (file)
 #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 <stdlib.h>
 #include <stdio.h>
 #include <IL/il.h>
 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<b)?(enhance(x,e-d,b-a,d*b-a*e)):e))));
+       return ((x<=a)?d:((x>=c)?f:((x>b)?(enhance(x,F-E,C-B,E*C-B*F)):((x<b)?(enhance(x,E-D,B-A,D*B-A*E)):e))));
+}
+
+ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c)
+{
+       return enhance(x,C-A,B-A,(B-C)*A);
 }
 
 int main (int argc, const char *argv[])
 {
-       ILubyte a,b,c,d,e,f;
+       ILubyte a,b,c,d,e,f,g;
+       ILubyte *h, *s, *l;
+       ILuint inX, inY;
+       ILubyte *newdata;
        
        if(argc<9)
                mustard(ARGUMENT_MUSTARD);
@@ -85,41 +100,54 @@ int main (int argc, const char *argv[])
        {
                for(unsigned long j=0;j<inY;++j)
                {
-                       //these things are #define'd
-                       if(CR>=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);
index 39974318d5ef83fcdb8ccdf3dad7441e48da34ab..ef514afc9c077c1aef016c2a863692568883a5e4 100644 (file)
@@ -3,7 +3,7 @@
        <head>
                <title>ENHANCE! &bull; Bicycles on the Moon</title>
                <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
-               <link rel="icon" type="image/png" href="/img/favicon.png"/>
+               <link rel="icon" type="image/png" href="/img/favicon.png">
        </head>
        <body>
                <a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.dnsd.info" border="0"></a>
@@ -13,8 +13,8 @@
                        <br>
                        a=<input type="text" name="a" value=  "0">, b=<input type="text" name="b" value= "34">, c=<input type="text" name="c" value= "41">,<br>
                        d=<input type="text" name="d" value=  "0">, e=<input type="text" name="e" value= "40">, f=<input type="text" name="f" value="255">.<br>
+                       a &lt; b &lt; c<br>
                        <br>
-                       
                        Enhance by URL<br>
                        URL of image:
                        <input type="text" name="inpix">
index 54ef52831f9548f5e28596c0874b5a7cc092774c..130b3d837040616fa90ce5b1403ea2c7161373f0 100644 (file)
@@ -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);