MATLAB:返回大矩阵中两个坐标之间的值数组(对角线)
如果我解释原因,这可能更有意义
我有一个逻辑矩阵(103x3488)输出测量人员的照片已经通过边缘检测(1=边缘,0=无边缘)。目的 - 计算标尺上刻度之间的像素距离。问题是,工作人员在中间下垂。
想法:用户输入员工每一端和下垂中点的坐标(使用ginput或其他东西),然后如果可以将这些点之间的边缘提取到数组中,我可以轻松找到边缘的位置。
有什么方法可以以这种方式从矩阵中提取数组吗?
也对其他想法持开放态度,只使用matlab一个月,所以大多数功能对我来说都是未知的。
编辑: 链接到 image
它显示了矩阵的一小部分区域,因此在本例中 1 和 2 是我想在之间进行采样,并且我想返回沿红线出现的点。
干杯
If I explain why, this might make more sense
I have a logical matrix (103x3488) output of a photo of a measuring staff having been run through edge detect (1=edge, 0=noedge). Aim- to calculate the distance in pixels between the graduations on the staff. Problem, staff sags in the middle.
Idea: User inputs co-ordinates (using ginput or something) of each end of staff and the midpoint of the sag, then if the edges between these points can be extracted into arrays I can easily find the locations of the edges.
Any way of extracting an array from a matrix in this manner?
Also open to other ideas, only been using matlab for a month, so most functions are unknown to me.
edit:
Link to image
It shows a small area of the matrix, so in this example 1 and 2 are the points I want to sample between, and I'd want to return the points that occur along the red line.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
矩阵
pdat
给出沿您选择的线的像素。meanspace
是以像素为单位的边缘间距。根据图像的不同,阈值可能需要调整。Try this
The matrix
pdat
gives the pixels along the line you have selected. Themeanspace
is edge spacing in pixel units. The thresholds might need fiddling with, depending on the image.看到图片后,我不确定你所说的“下垂”发生在哪里。图像已旋转,但您可以使用
imrotate
。需要旋转的程度应该足够容易;只需输入坐标
A
和B
并使用反正切求出相对于 0 度的角度偏移量。关于这些点,一旦直线对齐,您所需要做的就是在图像矩阵中指定一行(它将是一个 1 x 3448 向量)并使用
find
获取非零向量索引。由于旋转函数可能对像素进行了某种插值,因此每“行”可能会获得多个索引,但它们可以被识别为连续数字,并且您可以对它们进行平均以获得近似值。After seeing the image, I'm not sure where the "sagging" you're referring to is taking place. The image is rotated, but you can fix that using
imrotate
. The degree to which it needs to be rotated should be easy enough; just input the coordinatesA
andB
and use the inverse tangent to find the angle offset from 0 degrees.Regarding the points, once it's aligned straight, all you need to do is specify a row in the image matrix (it would be a 1 x 3448 vector) and use
find
to get non-zero vector indexes. As the rotate function may have interpolated the pixels somewhat, you may get more than one index per "line", but they'll be identifiable as being consecutive numbers, and you can just average them to get an approximate value.