Better pixel calculation method due to performance reasons
<p>I have a method which takes a <code>javafx.scene.paint.color</code> as a parameter and returns either <code>black</code> or <code>white</code> as a <code>color</code> depending on the <code>brightness</code> of the given <code>color</code>.</p>

<p>Here is my code:  </p>

<pre><code>@Override
public Color getPixelColor(Color color) {
    return color.getBrightness() &gt; cutOff ? Color.WHITE : Color.BLACK;
}
</code></pre>

<p>Because this has to be done for each <code>pixel</code> of an <code>image</code> this method can take a while depending of the <code>image size</code>. (For an Full HD Image the code will run through 2 million <code>if</code> statements)</p>

<p>So my question is, if there is a way/calcuation, which gives you <code>0</code>(black) or <code>1</code>(white) as result but doesn't use any <code>if</code> statements.</p>

<p>Thanks in advance.</p>