首页 > 解决方案 > 获取在 R 中用成像器加载的图片点的坐标

问题描述

让我们用imager.

library(imager)


file <- system.file('extdata/parrots.png',package='imager')
#system.file gives the full path for a file that ships with a R package
#if you already have the full path to the file you want to load just run:
#im <- load.image("/somedirectory/myfile.png")
im <- load.image(file)

plot(im) #Parrots!

在此处输入图像描述

我想得到这张图片中两点的坐标:眼睛,如下图:

在此处输入图像描述

如何获得两个点的 XY 坐标的数值?

标签: rimagecoordinates

解决方案


我找到了一个非常简单的解决方案:运行locator()你可以在图中的任意位置单击,在 Scaping 之后,我们得到 R shell 中的 XY 坐标。


推荐阅读