如何在R中保存二进制图像的XY坐标? [英] How do I save the XY coordinates of a Binary Image in R?

查看:153
本文介绍了如何在R中保存二进制图像的XY坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在R中保存二进制图像的XY坐标,类似于在ImageJ中保存保存XY坐标"功能.我已经浏览了一些可用于R的图像分析程序包,但还没有弄清楚如何完成此操作.

I am trying to save the XY coordinates of a binary image in R similarly to the save "Save XY Coordinates" function in ImageJ. I've looked through several image analysis packages available for R, but haven't yet figured out how to accomplish this.

推荐答案

在R中,有许多种方法可以完成以下操作:

There are many ways to do the following in R:

img_fil <- "~/data/ZjYqw.jpg"
img <- magick::image_read(img_fil)
img_df <- RSAGA::grid.to.xyz(as.matrix(as.raster(img)))

head(img_df)
##   x   y       z
## 1 0 599 #ffffff
## 2 1 599 #ffffff
## 3 2 599 #ffffff
## 4 3 599 #ffffff
## 5 4 599 #ffffff
## 6 5 599 #ffffff

这篇关于如何在R中保存二进制图像的XY坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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