蟒蛇 - 获取二维数组重要的价值坐标 [英] Python - Get coordinates of important value of 2D array

查看:172
本文介绍了蟒蛇 - 获取二维数组重要的价值坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确定从图像(二维数组)的角度。
我可以得到其强度为最大的点的坐标unravel_index和argmax,但我想知道如何获得另一点,其强度,以便计算我的角度高。
我必须automatise,因为我有-treatement后图像的大量

因此​​,对于第一个坐标,我能做到这一点:

 导入numpy的是NP
从numpy的进口unravel_indexT = unravel_index(eyy.argmax(),eyy.shape)

和我需要的另一个坐标,以便计算我的角度...

  T2 = ....THETA = np.arctan2(叔[0] -t2 [0],T [1] -t2 [1])


解决方案

有什么你可以尝试是寻找到霍夫变换(的维基百科 - Hough变换)。霍夫变换是查找线以及它们在图像取向开发了一种工具。

有在罗塞塔code

我不知道如果你的数据线是不同的足够霍夫变换的效果不好,但我希望它能帮助。

I would like to determine an angle from an image (2D array). I can get the coordinates of the point whose intensity is maximum with "unravel_index" and "argmax" but i would like to know how to get an another point whose intensity is high in order to calculate my angle. I have to automatise that because i have a great number of images for post-treatement

So for the first coordinates, i can do that :

import numpy as np
from numpy import unravel_index

t = unravel_index(eyy.argmax(), eyy.shape)

And i need an another coordinates in order to calculate my angle...

t2 = ....

theta = np.arctan2(t[0]-t2[0],t[1]-t2[1])

解决方案

What you could try is to look into the Hough Transform (Wikipedia - Hough Transform). The Hough Transform is a tool developed for finding lines and their orientation in images.

There is a Python implementation of the Hough Transform over at Rosetta Code.

I'm not sure if the lines in your data are distinct enough for the Hough Transform to yield good results but I hope it helps.

这篇关于蟒蛇 - 获取二维数组重要的价值坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆