[English text at the bottom]Hola Manolo
columna=5;
iniciofila=20;
finfila=100;
x=XPos();
y=YPos();
iif((x==columna)&&(y>iniciofila)&&(y<finfila),(Pixel($target,columna-1,y)+Pixel($target,columna+1,y))/2,$target)
Buen ejemplo de PixelMath. Puedes optimizar mucho esta expresión si en vez de asignar valores constantes a las variables columna, iniciofila y finfila, las defines como constantes en PixelMath. Para hacer esto, escribe lo siguiente en el campo Symbols:
x, y, columna=5, iniciofila=20, finfila=100
y entonces tu expresión queda así:
x=XPos();
y=YPos();
iif( x == columna && y > iniciofila && y < finfila, (Pixel( $T, columna-1, y ) + Pixel( $T, columna+1, y ))/2, $T )
En vez de $target se puede usar ahora $T, que es mucho más breve y simplifica las expresiones.
La mayoría de los paréntesis que estabas definiendo eran innecesarios, y hacían la expresión menos legible. En las expresiones lógicas y condicionales, ten en cuenta lo siguiente:
- La precedencia (orden de evaluación) de los operadores lógicos es la siguiente: ! ("no", negación), && ("y", intersección), || ("o", unión). En cuanto a precedencia, estos operadores son equivalentes a - (cambio de signo), * (multiplicación), + (suma), respectivamente.
- Los operadores relacionales (==, !=, <, <=, >, >=) tienen todos la misma precedencia, y ésta es siempre mayor que la de los operadores lógicos (se evalúan antes).
Por ejemplo, estas dos expresiones son equivalentes:
(a < b) || (b < c)
a < b || b < c
y éstas también:
(a && b) || (c && d)
a && b || c && d
sin embargo, éstas son diferentes:
a && b || c && d
a && (b || c) && d
Bienvenido a PixelMath. Siempre resulta sorprendente comprobar el tipo de cosas increíbles que se pueden hacer con esta herramienta. La mayoría de usuarios todavía no es consciente de lo enormemente potente que es. Y lo será más, porque aún no he terminado con ella, ni mucho menos
![Wink ;)](http://pixinsight.com/forum/Smileys/default/wink.gif)
==============================================
Hi Manolo
columna=5;
iniciofila=20;
finfila=100;
x=XPos();
y=YPos();
iif((x==columna)&&(y>iniciofila)&&(y<finfila),(Pixel($target,columna-1,y)+Pixel($target,columna+1,y))/2,$target)
Good PixelMath example. You can optimize this expression a lot if instead of assigning constant values to the columna, iniciofila and finfila variables, you define them as constants in PixelMath. To do that, write the following in the Symbols field:
x, y, columna=5, iniciofila=20, finfila=100
then your expression reduces to:
x=XPos();
y=YPos();
iif( x == columna && y > iniciofila && y < finfila, (Pixel( $T, columna-1, y ) + Pixel( $T, columna+1, y ))/2, $T )
Instead of $target you can use now $T, which is much more readable and simplifies expressions.
Most of the parentheses you had defined are unnecessary, and they were making your expression less readable. For logical and conditional expressions, note the following:
- Precedence (evaluation order) of logical operators is: ! ("not", logical negation), && ("and", intersection), || ("or", union). Regarding precedence, these operators are equivalent to - (sign change), * (multiplication), + (addition), respectively.
- Relational operators (==, !=, <, <=, >, >=) have all of them the same precedence, which is always higher than the precedence of logical operators.
For example, these two expressions are equivalent:
(a < b) || (b < c)
a < b || b < c
and these, too:
(a && b) || (c && d)
a && b || c && d
But these are different:
a && b || c && d
a && (b || c) && d
Welcome to PixelMath. It is always amazing all the incredible things that can be done with this tool. Most users still don't realize how powerful it is. And it will be more powerful, since I haven't finished its development, by no means
![Wink ;)](http://pixinsight.com/forum/Smileys/default/wink.gif)