This is a testing image, what am gonna do is putting a rasberry pi with cam on top of my plants in my greenhouse every morning it take images and process and send to me what’s going inside my greenhouse. that’s my goal
Its a melybug infestation it removed the background but it removed the infestation also. it would be great if you can suggest me a tool so i can work on it. Thanks
It looks like you have made progress with the color detection part. Fine tuning that part will be up to you, after you determine the color spectrum in your final images.
Here is some OpenCV Python code that may be useful:
https://docs.opencv.org/master/df/d9d/tutorial_py_colorspaces.html
That is similar to the process that I was going to suggest, but you need to make sure you know the color ranges first. HSV is probably the way to address this. I notice that you have already figured this out.
The next step is to change the non-black pixels to pure white (255, 255, 255) so your image is now just black and white. That will serve later as a mask.
Check the three images at the link above. The second shows artifacts. You would use morphological operators (erode, dilate, open, close, etc) to eliminate isolated small groups of pixels. That will fill in any small artifacts with white pixels.
Then finally, you use that as a ‘mask’ over the original image. That is done in the sample code by ‘bitwise and’. This will give you an image with just the pixels that you need to work with. All background should now be filtered out, so any subsequent operations (GLCM, neural nets, etc) will not be mis-triggering on background objects.
This in itself does not address the larger groups of pixels like the white ‘mealybugs’ above. I don’t think those were even in your original posts, were they? In fact, those may appear very different if your cameras are mounted up high. Any optimization that you attempt on close-ups may not work on distance photos. There are a number of ways to address specific cases like that after you have the main part of your code fine-tuned, and have the mask system working. I suggest that you move to actual representative images to do this.
PS: Get some ladybird beetles for the mealybugs.
PS: -AFTER- you get everything above working and fine-tuned, here’s how you address the mealybugs, and maybe other problems:
Do a separate pass, with all the steps above, but this time you would just use the color characteristics of the white mealybug pixels. You can then use GLCM to detect their texture. It will be very different from the smoother white pipes in your earlier photos.
The GLCM output matrix shows transitions between various gray levels. Transitions to/from black should be on the outer edge, so you can ignore them. That’s another advantage of turning all the background pixels solid black.
The point of all this is to extract as many useful features as possible. Then you can use a non-CNN neural net (‘fully connected nn’) or support vector machine to sort out the decisions.
so the end decision taken by neural network or just glcm ? got confused on that part,
GLCM does not make decisions. It will give you information (features) that you use to make decisions. The shades of green vs brown are a separate set of features that you would use in parallel with GLCM output to assist those decisions (they are separate sets of features).
I thought that you were using a support vector machine in some of your earlier code…? You could use anything that you want though: SVM, Decision Tree, Boosting, Neural Net, etc.
Which OpenCV books do you have? There are a couple that include machine learning.
Yes, am using svm to make decisions,. I don’t have any books about opencv i just refer internet that’s it. I’ve got a chance to read about Hyperspectral images, do you know anything about that ? after reading that they said it good for detecting plant disease better option than normal camera.
I talked with some guys in stackoverflow, they told me need deep learning to segment the leaf without losing the mealybugs that’s the only way to fine tune the data . is that true?
Jeffin, I can’t comment on someone else’s reasoning. I’ve done quite a lot of segmentation in images over the past years, and I’ve been able to solve some of the tasks that others insisted would absolutely require a neural net. I do understand neural nets, and I’ve taught people how they work. But I don’t assume that they’re the only tool in the box. They can do impressive things, but they have their down-sides. I think I covered some of this early in the thread.
Having said that… Try them. You’ll need to have the StackOverflow guys steer you through it though, cause that’s a bit far from the focus of the OpenCV forum. Make sure to ask them how much training data, and whether they are suggesting developing masks.
Also… Buy some books! If you count on forums and google searches for all of your knowledge, that base will be spotty. You should broaden out. I also suggested two very good machine learning/neural net books that will tell you what you need to know.
You also asked about hyperspectral: Yes, I know about that. How much are you going to spend on specialized sensors and software? You’d definitely need to study A LOT to get up to speed on the specialized range of technologies involved.
Good luck, Jeffin. I think I’ve provided all the info that I can, within the range of the forum.
Thanks, I understand
@StringTheory @berak i trained maskrcnn model and able to run it on opencv dnn
can you guys tell me how to crop the selected part ?