Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-24T16:06:39.107Z
Answers.Text: 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```
Answers.UserDisplayName: user984896
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-07T02:03:17.467Z
Answers.Text: @user984896 – [What should I do when someone answers my question?](https://video.stackexchange.com/help/someone-answers)
Answers.UserDisplayName: MarianD
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-22T06:11:13.123Z
Answers.LastActivityDate: 2018-09-22T06:11:13.123Z
Answers.UserDisplayName: Gyan
Body: <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>
  
Tags: <ffmpeg>
Title: ffmpeg convert non transparent pixel to white
UserDisplayName: user984896
ThreadText: # 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)  
  
  ---
  
  