The first problem is MEX. MEX is an interface between C/C++ and Matlab. I have an implementation of an algorithm written in C++, then, I want to integrate it into my matlab program. So I have to modify the original cpp file and make it working well with my M-files. The input data is very confusing. In Matlab, matrix is a string of elements and every element in the matrix is arranged in a row-first pattern, that means a(2,1), not a(1,2) is the next element of a(1,1). In addition, the data type is also very complicate. In matlab, numbers are stored in "double" by default, but in C++, there is no default and you are the only one control the data type. So, I forget to change the input data from "UNIT8" in a gray-level image to "double". The hole day is full filled with exceptions and breaks... It is too bad... and upset.
fortunately, I find the problem and fix it... It works well, right?!