问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/39562605/how-do-i-save-the-xy-coordinates-of-a-binary-image-in-r