OpenCv

Accessing each element in a matrix:

for( int i=0; i<rows; i++ ) {
		for( int j=0; j<cols; j++ ) { 
			result.at<float>(i, j) = src.at<float>(i+disparity, j+disparity);
			cout << result.at<float>(i, j) << " ";
		}
		cout << endl;
	}

Threshold:
Flags:

  • THRESH_BINARY

    \texttt{dst} (x,y) =  \fork{\texttt{maxval}}{if $\texttt{src}(x,y) > \texttt{thresh}$}{0}{otherwise}

  • THRESH_BINARY_INV

    \texttt{dst} (x,y) =  \fork{0}{if $\texttt{src}(x,y) > \texttt{thresh}$}{\texttt{maxval}}{otherwise}

  • THRESH_TRUNC

    \texttt{dst} (x,y) =  \fork{\texttt{threshold}}{if $\texttt{src}(x,y) > \texttt{thresh}$}{\texttt{src}(x,y)}{otherwise}

  • THRESH_TOZERO

    \texttt{dst} (x,y) =  \fork{\texttt{src}(x,y)}{if $\texttt{src}(x,y) > \texttt{thresh}$}{0}{otherwise}

  • THRESH_TOZERO_INV

    \texttt{dst} (x,y) =  \fork{0}{if $\texttt{src}(x,y) > \texttt{thresh}$}{\texttt{src}(x,y)}{otherwise}

API:

double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
Advertisements