How to translate MatExpr statements(comparing a Mat with int threshold) used in OpenCV in C++ to EmguCV in C#?

28 Views Asked by At

i'm translating my opencv c++ routines to emgucv c# platform.i've done all but one.here it is(c++ side):

Mat equalizeHistogram(Mat img,int threshold){
    Mat gray,equalized;
    cvtColor(img,gray,COLOR_BGR2GRAY);
    equalizeHist(gray,equalized);
    equalized=threshold < 128 ? (equalized < threshold ):(equalized > threshold );
    return equalized ;
}

it works perfect in c++ but in c# , emgucv doesnt accept operators < and > overloading(error:"operator < cannot be applied to operands of type 'Mat' and 'int' ").as i understand,in opencv these are done via a class called MatExpr which is absent in emguCV. seems i have to implement what these two operators do.but i'm a bit confused about it. is it true for 4th line of function?

a)if the given threshold<128 then compare all values of Mat by threshold and let them remain the same value below threshold but 0 for all which above the threshold.

b)if the given threshold>128 then compare all values of Mat by threshold and let them remain the same value above threshold but 0 for all which below the threshold.

how can i implement such a thresholding?or what's the proper usage of thresholding functions of opencv in order to do exactly the same as my c++ function? thanks in advance.

0

There are 0 best solutions below