tree recognition in plan view , identification through pixel pattern
in
Programming Questions
•
2 years ago
hello, i am completely new to processing, i had just completed the tutorials.
i have started writing code that takes an image, and goes through every pixel; then it tells me if the 15 or so pixels to the right of this pixel has a green/black pattern.
what i have a plan image of trees and houses, and i want the script to place a point on each tree.
i know that the trees have a similar pattern of dark to green to dark pattern, and i think i can identify trees using this method.
i 'think' i have already written some code that goes through each pixel and looks at its surroundings, but i do not know how to identify the colour patterns around this .
what i need help with is in the identification part..
this is what i have right now, trying to modify the findEdge script
float[][] kernel = { { -1,-1, -1, -1,-1 },
{ -1,-1, -1, -1,-1 },
{ -1,-1, 19, -1,-1 },
{ -1, 1, -1,-1,-1 },
{ -1, -1, -1,-1,-1 } };
size(542, 166*2);
PImage img = loadImage("test small 1.jpg");
image(img, 0, 0);
img.loadPixels();
PImage treeImg = createImage(img.width, img.height, RGB);
for (int y = 10; y < img.height - 10; y++){
for (int x = 10; x < img.width - 10; x++) {
float sum = 0;
for (int ky = -2; ky <= 2; ky++) {
for (int kx = -2; kx <= 2; kx++) {
int pos = (y + ky)*img.width + (x + kx);
float val = green(img.pixels[pos]);
sum += kernel[ky+2][kx+2] * val;
}
}
treeImg.pixels[y*img.width + x] = color(sum);
}
}
treeImg.updatePixels();
image(treeImg, 0, 167);
if there is any other methods, will you please link me to it?
1