After a twenty year hiatus from programming, I'm jumping back into the mix and need a little help. I've done a lot of searching on these forums and the web trying to find something close that could give me a direction, but I'm stumped.
I'm trying to write a sketch that will search an image for green dots of a known radius and create a symbol in the center of those dots. Eventually it will loop to search for other colors and spawn other symbols.
My problem is figuring out how to evaluate the surrounding pixels based on a radius rather than a box matrix.
Thanks for the help.
Heres the code so far:
PImage img_existing;
void setup() {
size (200,200);
background (70);
img_existing = loadImage("find_test.png"); //200,220 image with dots
}
void draw() {
// define what color to search for
search_color = color(0,255,0)
//Call function to find the dots
Find_Existing(img_existing, 10, search_color);
}
// Function for finding the existing dots
void Find_Existing(PImage _img, int dot_radius, color(_search_color)) {
//Load the pixels of the screen
_img.loadPixels();
//loop through each pixel
for (int y = 0; i < height; y++) {
for (int x = 0; x < width; x++) {
//location in the pixel array is determined by
int loc = x + y*width;
// pull out the rgb values for the pixels
float r = red (_img.pixels [loc];
float g = green (_img.pixels [loc];
float b = blue (_img.pixels [loc];
/*
The radius check: if the surrounding pixels in the given radius around
the pixel being evaluated is equal to the specified color then spawn
an ellipse.
This is where I need help... not with the ellipse though ;)