6 Replies Latest reply: Sep 20, 2010 5:33 PM by George Austin RSS

    Filter factory limitation on clauses?

    George Austin Community Member

      I have encountered what may be a limitation on the number of clauses in filter factory coding and would like someone to confirm or debunk it.

       

      I have written 12 lines of code, all similar, all containing three && "and" operators, and all ending with the || "or" operator except the last line which ends by concluding an overall "If-Then" statement. The caution icon comes on when the ninth line is added and one of the && signs gets highlighted as the error source. Yet, that line is basically no different in structure from any of the others. Only when I backspace out the ninth and subsequent lines does the caution disappear and the filter respond. 

        • 1. Re: Filter factory limitation on clauses?
          Noel Carboni Community Member

          I'll start by saying I'm not a Filter Factory expert, but just thinking about basic logic for a moment, is it possible the "caution" indicator is telling you that you need to group your clauses?

           

          A && B || C can be ambigious, and will depend on the order of execution.

           

          (A && B) || C is unambiguous.

           

          -Noel

          • 2. Re: Filter factory limitation on clauses?
            Mylenium CommunityMVP

            Without providing the code such questions are pretty pointless, but I tend to agree with Noel that you are creating an ambiguous state and there can be no logical branching...

             

            Mylenium

            • 3. Re: Filter factory limitation on clauses?
              George Austin Community Member

              Here's the code in the R box:


              x<128  && y<128    && r>g  && g>b   && (128*b) >(r*x)  ||
              x<128  && y<128    && r>b  && b>g   && (128*g) >(r*x)  ||
              x<128  && y<128    && r>b  && b>g   && (128*g) >(r*y)  ||
              x<128  && y<128    && g>r  && r>b    && (128*b) >(g*x)  ||
              x<128  && y<128    && g>r  && r>b    && (128*b) >(g*y)  ||
              x<128  && y<128    && g>b  && b>r   && (128*r) >(g*x)   ||
              x<128  && y<128    && g>b  && b>r   && (128*r) >(g*y)   ||
              x<128  && y<128    && b>r  && r>g    && (128*g) >(b*x)  ||
              x<128  && y<128    && b>r  && r>g    && (128*g) >(b*y)  ||
              x<128  && y<128    && b>g  && g>r   && (128*r) >(b*x)   ||
              x<128  && y<128    && b>g  && g>r   && (128*r) >(b*y)  ? 255:r

               

               

              Works until I add the last three lines keeping, of course, the If_Then_Else conclusion "?255:r"

              If I add any one or two or all of the last three lines, the caution comes on.

               

              The G and B boxes are identical except they end with g and b, respectively. They behave the same way as the R box, as you would expect.

              • 4. Re: Filter factory limitation on clauses?
                George Austin Community Member

                The second line got cut out. Corrected code below:

                 

                 

                x<128  && y<128    && r>g  && g>b   && (128*b) >(r*x)  ||
                x<128  && y<128    && r>g  && g>b   && (128*b) >(r*y)  ||
                x<128  && y<128    && r>b  && b>g   && (128*g) >(r*x)  ||
                x<128  && y<128    && r>b  && b>g   && (128*g) >(r*y)  ||
                x<128  && y<128    && g>r  && r>b    && (128*b) >(g*x)  ||
                x<128  && y<128    && g>r  && r>b    && (128*b) >(g*y)  ||
                x<128  && y<128    && g>b  && b>r   && (128*r) >(g*x)   ||
                x<128  && y<128    && g>b  && b>r   && (128*r) >(g*y)   ||
                x<128  && y<128    && b>r  && r>g    && (128*g) >(b*x)  ||
                x<128  && y<128    && b>r  && r>g    && (128*g) >(b*y)  ||
                x<128  && y<128    && b>g  && g>r   && (128*r) >(b*x)   ||
                x<128  && y<128    && b>g  && g>r   && (128*r) >(b*y)  ? 255:r

                • 5. Re: Filter factory limitation on clauses?
                  Noel Carboni Community Member

                  How is this evaluated?  Does && bind more tightly than ||?

                   

                  If they're equal in precedence, and it's left to right, your expression makes little sense.

                   

                  What I was saying is that maybe you want to use more ( and ) to group the subexpressions so that you can both ensure in which order they are evaluated, and to possibly help the parser deal with such a long expression.

                   

                  -Noel

                  • 6. Re: Filter factory limitation on clauses?
                    George Austin Community Member

                    saturation decrease areas in SW quadrant.jpg

                     

                    The filter is applied to a pre-existing 255x255 pixel image with linear gradients left-to-right for red, top-to-bottom for green, and with blue constant at 128, after the image has been altered in LAB by rotating the LAB b channel curve CCW. It is supposed to color pixels white if their saturation has decreased, else leave them unchanged as part of addressing the question of what happens to saturation when the LAB curve is rotated CCW or CW. Each quadrant is treated separately because the initial saturation parameter varies with quadrant (and by half-quadrant in two of them).

                     

                    The problem is NOT a limitation on the number of Filter Factory clauses as I too quickly assessed it. There is a logic glitch in the NW quadrant code which I am working to eliminate. The 12 lines represent 12 mutually exclusive conditions, only one of which can exist at a given pixel site but any of which might exist at different sites. Hence the sequence of "or" statements.

                     

                    The SW quadrant is simpler and I took a different approach with it. The results for it (attached---with the LAB b channel rotared to +/- 64) illustrate the objective.