How to eliminate noise in an image?

0

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)
    
asked by anonymous 06.12.2018 / 01:46

1 answer

0

OpenCV provides 4 techniques for noise suppression, one of which is the cv.fastNlMeansDenoisingColored() function.

The parameters are: (original,destino,7,21,h,hColor) , where h is the parameter that regulates the filter, large values of h remove noise well, but the image loses detail. For hColor is the same idea as h .

imagem_dst = cv2.fastNlMeansDenoisingColored(imagem,None,7,21,7,21)
cv2.imshow("Teste",imagem_dst)

You can see the parameters here

    
06.12.2018 / 14:40