In relation to the image presented, I want to leave only the main trunk and branches (secondary) of the plant (tomato) very visible.
Asaresultofmyattempts,whatseemstometobethemostencouragingresultsisthereductionoftheimagearea,followedbytheCannyborderdetector.
Butthere'sstillalotofwhatIthinkcanbecallednoise.IfIcaneliminatethosemanysmallwhite"spots" (noise), I would be practically alone with the shapes (edges) of the branches of the plant, as intended.
What will be the best way to do this?
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)