sortIdx
import { sortIdx } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Sorts each row or each column of a matrix.
The function cv::sortIdx sorts each matrix row or each matrix column in the ascending or descending order. So you should pass two operation flags to get desired behaviour. Instead of reordering the elements themselves, it stores the indices of sorted elements in the output array. For example:
Mat A = Mat::eye(3,3,CV_32F), B;
sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
// B will probably contain
// (because of equal elements in A some permutations are possible):
// [[1, 2, 0], [0, 2, 1], [0, 1, 2]]
See: sort, randShuffle
sortIdx(src: Mat, dst: Mat, flags: number): void;srcinput single-channel array.
dstOutput destination, filled by the native operation. output integer array of the same size as src.
flagsoperation flags that could be a combination of cv::SortFlags
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.