My objective is to be able to obtain the size, in pixels, of objects in images I'm receiving from a camera.
I've tried two approaches thus far, both working to some extent, and I'm wondering if there's any other approach you can suggest.
The first approach was using the CIE Delta E formulas. I would parse through the BGR 24 image data and then locate the appropriate pixels that form part of the object I wish to size. This approach works well when I know the object colors and positions beforehand, not so much when I don't. Another drawback of this approach is that calculating the Delta E for every pixel is extremely computationally expensive.
To circumvent my reliance on having to know the colors and positions beforehand, I used Connected-component Labeling to find the objects and size them.
Here's an example of what I'm doing using connected component labeling.
As you can see from the image above, I'm making four measurements, horizontal, vertical, left diagonal, and right diagonal. After I've sized the object I know where it is in the image, I then debayer the image into a BGR24 image and take several color samples. Debayering the image constitutes about 50% of the processing time, which is more than I prefer.
Now, my question is: What other approaches are there for finding the size in pixels of objects in an image?