# BlobDetection library: Can it find light-colored blobs instead of only dark ones?

**URL:** <https://discourse.processing.org/t/blobdetection-library-can-it-find-light-colored-blobs-instead-of-only-dark-ones/36755>\
**Category:** Libraries\
**Created:** [May 7, 2022, 9:51am UTC](https://discourse.processing.org/t/blobdetection-library-can-it-find-light-colored-blobs-instead-of-only-dark-ones/36755 "2022-05-07T09:51:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamshark70](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@jamshark70](https://discourse.processing.org/u/jamshark70)\
**Post date:** [May 7, 2022, 9:51am UTC](https://discourse.processing.org/t/blobdetection-library-can-it-find-light-colored-blobs-instead-of-only-dark-ones/36755/1 "2022-05-07T09:51:01Z")

</div>

Hi.

A bit puzzled with something in the blobDetection library (Julien ‘v3ga’ Gachadoat, [BlobDetection library / v3ga](http://www.v3ga.net/processing/BlobDetection/)).

I adapted the webcam script to display the blobs and also send blob coordinates over OSC.

It identifies blobs of darker color, compared to lighter surroundings.

I wanted to reverse this behavior: to get blobs for lighter image areas.

So I inserted `filter(INVERT);` immediately after copying the camera data into a separate image.

```auto
void draw()
{
	if (newFrame)
	{
		newFrame=false;
		scale(-1, 1); // horizontal flip
		image(cam, 0, 0, -width, height);
		img.copy(cam, 0, 0, cam.width, cam.height, 
				0, 0, img.width, img.height);
		filter(INVERT);
		fastblur(img, 2);
		theBlobDetection.computeBlobs(img.pixels);
		drawBlobsAndEdges(true, true, true);
	}
}

```

_Without_ `filter(INVERT)`, blobs consist of darker screen areas.

_With_ `filter(INVERT)`, blobs consist of lighter screen areas – same areas as before.

Should I assume, then, that `filter(INVERT)` only affects display but does not affect the image contents?

Is there a function that inverts the actual pixel values? I go to [Reference / Processing.org](https://processing.org/reference#image) and search this page for “invert” and find only a Boolean “not” operator, which is certainly not the right thing.

If I wanted to track hands, for instance, currently the only way to get a meaningful result would be to wear a white shirt and black gloves. What if I wanted to wear a dark shirt and no gloves? That’s the point.

hjh

---

<div class="post-metadata">

**Author:** ![m0nsterm0vi3](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@m0nsterm0vi3](https://discourse.processing.org/u/m0nsterm0vi3)\
**Post date:** [May 31, 2023, 11:53pm UTC](https://discourse.processing.org/t/blobdetection-library-can-it-find-light-colored-blobs-instead-of-only-dark-ones/36755/2 "2023-05-31T23:53:17Z")

</div>

I want to use a sketch to track the motion of fireflies and send co-ordinates over OSC to Pure Data. So I’d love to know how this project came along? Dark blobs are no use to me, I need to track the lightest points on the camera feed! Thanks.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 8, 2023, 3:52pm UTC](https://discourse.processing.org/t/blobdetection-library-can-it-find-light-colored-blobs-instead-of-only-dark-ones/36755/3 "2023-06-08T15:52:28Z")

</div>

Hello @m0nsterm0vi3 ,

This topic may be of interest to you:

> [@How to use SPOUT input with 11.10: Computer Vision: Adding Lifespan to Blobs - Processing Tutorial](https://discourse.processing.org/t/how-to-use-spout-input-with-11-10-computer-vision-adding-lifespan-to-blobs-processing-tutorial/40735):
>
> Hi, I am relatively new to Processing. I am trying to make the Blobtrack Persistance example (as seen in [this](https://www.youtube.com/watch?v=o1Ob28sF0N8) video) work with Input from SPOUT receiver instead of the webcam input. Does anybody have an advice for me? Many thanks in advance, Marijn

> [@jamshark70](#):
>
> Should I assume, then, that `filter(INVERT)` only affects display but does not affect the image contents?
> 
> Is there a function that inverts the actual pixel values?

I adapted this example:  
[https://processing.org/reference/libraries/video/Capture.html](https://processing.org/reference/libraries/video/Capture.html)

And this code (modify example above) will invert and display the image:

```auto
void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  
  image(cam, 0, 0);
  
  PImage img = cam.copy();
  
  img.filter(INVERT);
  image(img, width/2, 0); // Moved it over
}

```

`:)`
