获取已排序矩阵的索引

时间:2015-07-29 07:36:25

标签: python sorting matrix indexing

我有一个2D np.array:

cv::findContours(result,found_contour,found_hierachy,CV_RETR_TREE,CV_CHAIN_APPROX_SIMPLE,cv::Point(0,0));

std::vector<Contours> contour_struct;
contour_struct.reserve(found_contour.size());

for (size_t i = 0; i < found_contour.size(); i++)
{
    contour_struct[i].contour = found_contour[i];
    contour_struct[i].minRect = cv::minAreaRect(cv::Mat(found_contour[i]));
}

我想按值提取这个np.array的排序索引 结果应该是(例如): array([[ 1523., 172., 1613.], [ 3216., 117., 1999.], [ 85., 1271., 4.]])

我已经看过如何提取min:

[[2,2],[2,0],[1,1],[0,1],[2,1],[0,0],[0,2],[1,2],[1,0]]

谢谢

1 个答案:

答案 0 :(得分:2)

numpy.argsortL一起使用(假设展平数组):

axis=None