<p>The two operand <code>if</code> expression returns 0 if the condition isn't met. You need the three operand version.</p>

<pre><code>if(lt(alpha(X,Y),10),255,p(X,Y))
</code></pre>

CC BY-SA 4.0
2018-09-24T16:06:39.107Z
Thanks, the final one that worked for me is: ```ffmpeg -y -i in.png -vf "format=rgba,geq='r=if(gt(alpha(X,Y),128),255,0):g=if(gt(alpha(X,Y),128),255,0):b=if(gt(alpha(X,Y),128),255,0):a=if(gt(alpha(X,Y),250),255,0)'" x.png && open x.png```
user984896
CC BY-SA 4.0
2022-08-07T02:03:17.467Z
@user984896 – [What should I do when someone answers my question?](https://video.stackexchange.com/help/someone-answers)
MarianD
CC BY-SA 4.0
2018-09-22T06:11:13.123Z
2018-09-22T06:11:13.123Z
Gyan
<p>I'm trying to convert all non-transparent pixels of an image to white using the geq filter in ffmpeg:
<code>ffmpeg -y -i in.png -vf "format=rgba,geq='r=if(lt(alpha(X,Y),10),255):g=if(lt(alpha(X,Y),10),255):b=if(lt(alpha(X,Y),10),255):a=alpha(X,Y)'" x.png
</code></p>

<p>But ffmpeg is giving me black pixels instead of white. Any ideas what is going on?</p>

<p>in.png: </p>

<p><a href="https://i.sstatic.net/Dh36M.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Dh36M.png" alt="enter image description here"></a></p>

<p>out.png: </p>

<p><a href="https://i.sstatic.net/g8q1L.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/g8q1L.png" alt="enter image description here"></a></p>

<ffmpeg>
ffmpeg convert non transparent pixel to white
user984896
# ffmpeg convert non transparent pixel to white

(Asked by: username_0 on 2018-09-21)

I'm trying to convert all non-transparent pixels of an image to white using the geq filter in ffmpeg:
`ffmpeg -y -i in.png -vf "format=rgba,geq='r=if(lt(alpha(X,Y),10),255):g=if(lt(alpha(X,Y),10),255):b=if(lt(alpha(X,Y),10),255):a=alpha(X,Y)'" x.png`

But ffmpeg is giving me black pixels instead of white. Any ideas what is going on?

in.png:

[![enter image description here](https://i.sstatic.net/Dh36M.png)](https://i.sstatic.net/Dh36M.png)

out.png:

[![enter image description here](https://i.sstatic.net/g8q1L.png)](https://i.sstatic.net/g8q1L.png)

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2018-09-22. Score: 1

The two operand if expression returns 0 if the condition isn't met. You need the three operand version.
if(lt(alpha(X,Y),10),255,p(X,Y))

> **Comments:**
> **username_0**: Thanks, the final one that worked for me is: ```ffmpeg -y -i in.png -vf "format=rgba,geq='r=if(gt(alpha(X,Y),128),255,0):g=if(gt(alpha(X,Y),128),255,0):b=if(gt(alpha(X,Y),128),255,0):a=if(gt(alpha(X,Y),250),255,0)'" x.png && open x.png```  
> **username_2**: @username_0 – [What should I do when someone answers my question?](https://video.stackexchange.com/help/someone-answers)  

---

