2
In relation to the image presented, I want to leave only visible the main trunk and the (secondary) branches of the plant (tomato).
Depending on my attempts, what seems to me to give more encouraging results is the reduction of the image area, followed by the application of the Canny edge detector.
But there’s still a lot of what I think you might call noise. If I can eliminate those many small white "spots" (noise), I would be practically only with the shapes (edges) of the branches of the plant as intended.
What’s the best way to do that?
Code:
import numpy as np
import cv2
imagem = cv2.imread("tomat.jpg")
print(imagem.shape)
for y in range(0, 360):
for x in range(0, 120):
imagem[y, x] = (0,0,0)
for y in range(0, 360):
for x in range(250, 480):
imagem[y, x] = (0,0,0)
gris = cv2.cvtColor(imagem, cv2.COLOR_BGR2GRAY)
# Aplicar suavizado Gaussiano
gauss = cv2.GaussianBlur(gris, (5,5), 0)
# Detectamos los bordes con Canny
canny = cv2.Canny(gauss, 50, 150)
cv2.imshow("canny", canny)
cv2.waitKey(0)
opencv has a function called
normalize
I use it in facial recognition and solved much of the problem– Jasar Orion
You don’t just want to "eliminate the noise". You need to pass the image through several stages so that at the end, you have in prominence, the characteristics that interest you. The best is to read some theoretical text, or a course on image processing, and in the study you discover the sequence of filters that will be more interesting to apply to get to where you want.
– jsbueno
Alternatively, you can open an image editor with a graphical interface, like GIMP, and see, if through interactive manipulations with multiple filters, you can separate only what interests you- then annotate the steps, and write a script that does this, calling the same filters.
– jsbueno