Using R for a simple pattern / pattern recognition task?

I have an image with many dots, and I would like to extract from it what is the xy place of each dot.

I already know how to do this manually (there is a package for this).

However, is there a way to do this automatically?

(My next question will be - is there a way when there is an image of many lines to detect where the lines intersect / “touch each other”)

Due to queries in the comments, here is an example for an image to "solve" (for example: retrieving the locations of data points for it)

#riddle 1 (find dots): plot(cars, pch = 19) #riddle 2 (find empty center circles): plot(cars, pch = 1) #riddle 2 (fine intersection points): plot(cars, pch = 3) #riddle 3 (find intersections between lines): plot(cars, pch = 1, col = "white") lines(stats::lowess(cars)) abline(v = c(5,10,15,20,25)) 

Thanks Tal

(ps: since I am not familiar with this field, I am sorry if I use the wrong terminology or ask too simple or complex question. Is this OMR ?)

+4
source share
3 answers

I think you could use the raster package to extract the xy coordinates from an image with specific values. Look at the package vignettes.

EDIT

Can you try this and tell me if this is in a ball park, what are you looking for? I hope the comment code is fully explainable. Looking forward to your reply!

 library(raster) rst <- raster(nrows = 100, ncols = 100) #create a 100x100 raster rst[] <- round(runif(ncell(rst))) #populate raster with values, for simplicity we round them to 0 and 1 par(mfrow=c(1,2)) plot(rst) #see what you've got so far rst.vals <- getValues(rst) #extract values from rst object rst.cell.vals <- which(rst.vals == 1) #see which cells are 1 coords <- xyFromCell(rst, rst.cell.vals) #get coordinates of ones rst[rst.cell.vals] <- NA #set those raster cells that are 1 to NA (you can play with rst[!rst.cell.vals] <- NA to exclude all others) plot(rst) #a diag plot, should have only one color 
+2
source

Medical imaging. Viewing a task covers a general image; this may be the beginning.

+4
source

Following Dirk, yes check the presentation of the medical imaging task. Also look at Rforge, Romain Francois had an RJImage package, and another image processing package has recently been registered. You are looking for segmentation algorithms. The problem with your points is much simpler than the problem with the line. The first can be done using an RGB filter or grayscale, just performing a radius search. Detecting linear characteristics is more difficult. After you extract the extracted functions, you can use the sweepline algorithm to detect intersections. An EBI image may have an example for detecting cells in a vignette.

Nicholas

+4
source

Source: https://habr.com/ru/post/1314205/


All Articles