# How to know if certain pixel is red, or blue, or green

**URL:** <https://discourse.processing.org/t/how-to-know-if-certain-pixel-is-red-or-blue-or-green/33802>\
**Category:** Beginners\
**Created:** [November 28, 2021, 4:58pm UTC](https://discourse.processing.org/t/how-to-know-if-certain-pixel-is-red-or-blue-or-green/33802 "2021-11-28T16:58:00Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [November 30, 2021, 8:13pm UTC](https://discourse.processing.org/t/how-to-know-if-certain-pixel-is-red-or-blue-or-green/33802/9 "2021-11-30T20:13:49Z")

</div>

well a simple solution would be to search the distance on a 3D color cube. If a color must be either Red, green or blue, you can just find the closest point. Posterization filters work in a similar way (can work).

> [@My projects library #4! Gallery Megathread](https://discourse.processing.org/t/my-projects-library-4-gallery-megathread/31103/20):
>
> #55 Simple posterization filter Posterization filter sets the maximum amount of colors used. All colors on the screen get converted into those. [explanation by josephh](https://discourse.processing.org/t/posterization-filter-explained/32001/3)
> 
> > **Code**
> >
> > int clrs = 3; //end has clrs^3 colors, (1-1, 2-8, 3-27, 4-64, 5-125, 6-216,...) color clr[]; PImage img; void setup() { size(640,642); clr = generateColors(clrs); img = loadImage("house2.jpg"); println(img.width,img.height); } void draw() { image(img,0,0); noLoop(); loadPixels(); for(int i =…

here is a project that incorporates it.

---

_[View the full topic](https://discourse.processing.org/t/how-to-know-if-certain-pixel-is-red-or-blue-or-green/33802)._
