How can i identify/count how many objects are there in a image that has overlaps

2

The problem is I am trying to identify plants from a drone image. The plants from the image contain overlaps and are of different shapes/sizes. I am unsure of where to look or what types of methods to use for this and am looking for suggestions.

I have taken snippets from a full image of the fields and attempted to: Use Convolusion Neural Networks to train a xml file that was used in a java program, Used convulsion 3x3 matrixes such as sharpen and edge detection (specifically focused around Sobel and Laplace), identify each plant by taking their RGB values and greying out all others. I have focused efforts on the 3rd method of identifying their individual RGB values however this is difficult due to all of them having different values.

This is the current code I use to scan and remove irrelevant RGB values: I only store red and blue because a funny thing is, the green values of plants and that of background are actually nearly identical.
Here is a image of the field: enter image description here

I also have a few other images of the ways I have tried so far: The result of using sobel operator

//important data

int pixX = 330; //resolution of image
int pixY = 370;
int pixT = pixX * pixY; //total amount of pixels

int xloc = 0;//used to locate pixels to remove
int yloc = 0;
File test = new File("FILE.png)
int x = 0, y = 0; //Current XY values
int colorsplit[][] = new int[2][pixT];//obtaining red and blue will be stored in this 2d array

try {
        for (int c = 0; c < pixT - 1; c=c+2) { //I use C+2 to jump 2 pixels to make the process faster

BufferedImage image = ImageIO.read(test);//buffered image read

int clr = image.getRGB(x, y); //getting values as binary(? i think)
int red = (clr & 0x00ff0000) >> 16; //bit shifting for red values
    int blue = clr & 0x000000ff; //Blue values

for (int n = 0; n < 4; n++) { // this is used to store values so that a single run will store the same value twice for 2 pixels side by side (efficiency measures)

switch (n) {//switch to store Red Blue codes
case 0:
            colorsplit[0][c] = red;//store
    break;
case 1:
        colorsplit[1][c] = blue;//store
    break;

case 2:
    colorsplit[0][c + 1] = red;//store
    break;
case 3:
    colorsplit[1][c + 1] = blue;//store
        }

}//END switch
    x = x + 2;
if (x == pixX) {//Going up in XY values to cover all values
    x = 0;
    y++;
    }//end if
}//end for

     ...//end of try, catch IOException

for (int c = 0; c < pixT; c++) { //Starting to identify redundant pixels

    if (colorsplit[0][c] > 200 || colorsplit[1][c] > 100) { //parameters of redundant pixels

xloc = c % pixX;
yloc = c / pixX;//locating XY pixels

image.setRGB(xloc, yloc, 0); //Setting redundant pixels to black
System.out.println(xloc + "," + yloc + " setted"); //confirmation text

    }//end for
//end

I do not get many errors however the problem lies more with the program not working as intended.

Edit: Turns out most things were fine, but one thing I didn't do was combine multiple identification programs. Ended up doing RGB reduction to only get R values followed by a Sobel operator and then using pixel by pixel analysis to filter out the redundant pixels.

java
eclipse
image-processing
computer-vision
detection
asked on Stack Overflow Jul 8, 2019 by Orion • edited Jul 11, 2019 by Orion

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0