2014-09-23 16 views
5

Non ho bisogno dell'immagine con soglia. Voglio la soglia. Ho trovato questo in OpenCV.Qual è la funzione per trovare la soglia di otsu in emgu cv?

cv::threshold(orig_img, thres_img, 0, 255, CV_THRESH_BINARY+CV_THRESH_OTSU); 

Esiste un equivalente in EmguCv. Grazie in anticipo.

PS. Devo utilizzare questa soglia per il rilevatore di bordo canny

+0

nessuna idea di emgu, ma il * valore di ritorno * di cv :: threshold è la soglia di otsu nel caso precedente. (quindi probabilmente hai ancora bisogno di chiamare cv :: threshold, anche se butti via thresh_img) – berak

+0

Grazie! Ho chiamato la funzione di soglia tramite CvInvoke e funziona – Siddarth

risposta

8

È possibile consultare questo codice per il rilevatore di bordo automatico Canny!

Image<Gray, byte> Img_Source_Gray = Img_Org_Gray.Copy(); 
Image<Gray, byte> Img_Egde_Gray = Img_Source_Gray.CopyBlank(); 
Image<Gray, byte> Img_SourceSmoothed_Gray = Img_Source_Gray.CopyBlank(); 
Image<Gray, byte> Img_Otsu_Gray = Img_Org_Gray.CopyBlank(); 

Img_SourceSmoothed_Gray = Img_Source_Gray.SmoothGaussian(3); 
double CannyAccThresh = CvInvoke.cvThreshold(Img_EgdeNR_Gray.Ptr, Img_Otsu_Gray.Ptr, 0, 255, Emgu.CV.CvEnum.THRESH.CV_THRESH_OTSU | Emgu.CV.CvEnum.THRESH.CV_THRESH_BINARY); 
double CannyThresh = 0.1 * CannyAccThresh; 
Img_Otsu_Gray.Dispose(); 

Img_Egde_Gray = Img_SourceSmoothed_Gray.Canny(CannyThresh, CannyAccThresh); 
imageBox2.Image = Img_Egde_Gray; 
+1

Grazie. Funziona!. Non sapevo che puoi chiamare le funzioni OpenCV direttamente usando CvInvoke. – Siddarth

+0

So che questo post è piuttosto vecchio ma qualcuno conosce il codice di equivalenza per EmguCV 3.x? Perché non contiene la funzione CvInvoke.cvThreshold e l'enum Emgu.CV.CvEnum.THRESH. –