Java Code Examples for org.opencv.core.Core.norm()

The following are Jave code examples for showing how to use norm() of the org.opencv.core.Core class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: classchecks   File: Recognition.java   View Source Code Vote up 5 votes
/**
 * 计算两幅图像像素之间的相似性
 * <p>使用基于L2范数的相对错误评价标准,该标准是将两个图像的相应像素值相减,并对所
 * 得的差值求平方和,然后在对结果求平方根</p>
 * @param A
 * @param B
 * @return
 */
public static double getSimilarity(Mat A, Mat B) {
	if(A.rows() > 0 && A.rows() == B.rows() && A.cols() > 0 && A.cols() == B.cols()) {
		double errorL2 = Core.norm(A, B, CV_L2);
		double similarity = errorL2 / (double)(A.rows() * A.cols());
		return similarity;
	}
	return INVALID_IDENTIFICATION;
}