How to add text to an image in R based not on specific coordinates but features of the image

118 Views Asked by At

I'm trying to use R to annotate images (as either png or tiff) of tumor samples with a value according to where the corresponding region number is on the image. The numbers next to the circles represent certain regions where protein expression was taken. Here is an example of what I'm trying to do that I did by hand in powerpoint:

Photo of a tumor sample with values next to specific numbers on the sample

I have a dataframe (could be a named list) of values with the region number and value for the protein of interest. Here is a snippet of the data:

        Patient1_001    Patient1_002    Patient1_003
Ki-67         0.0162          0.0707           0.177

I could just keep annotating these images in powerpoint by hand, but that would be very inefficient as I will eventually have hundreds of these images. Is there a way in R to add the values next to their corresponding region without knowing the coordinates of the region? Is there a package/function/etc to just identify the number and put the correct value next to it? For example: recognize "001" in the image and add "0.0162" onto the image next to the "001"

I know a bit of python too so if this would be easier in python I'm open to that.

0

There are 0 best solutions below