如何从R中96孔微孔板荧光图像中提取像素值

如何从R中96孔微孔板荧光图像中提取像素值,r,loops,image-processing,R,Loops,Image Processing,我无法从R中的微量滴定板图像中提取像素强度值。我使用EBImage对图像进行阈值和分割,但当我这样做时,我丢失了原始图像的实际强度值 从.png图像开始,如下所示: 我需要识别每个单独的孔,并计算每个孔内的平均强度(它们是孔板中的叶盘)。因此,我想从这张图片中得到81个值 接下来,我需要在矩阵中提取这些值,我可以使用这些值从同一块板的不同图像中执行操作。因此,分割需要可重复使用,这样我就可以读取同一块板的其他图像,并提取相应的井值。图像大小完全相同,井的位置不变。在几个小时内拍摄了数百张这个盘

我无法从R中的微量滴定板图像中提取像素强度值。我使用EBImage对图像进行阈值和分割,但当我这样做时,我丢失了原始图像的实际强度值

从.png图像开始,如下所示:

我需要识别每个单独的孔,并计算每个孔内的平均强度(它们是孔板中的叶盘)。因此,我想从这张图片中得到81个值

接下来,我需要在矩阵中提取这些值,我可以使用这些值从同一块板的不同图像中执行操作。因此,分割需要可重复使用,这样我就可以读取同一块板的其他图像,并提取相应的井值。图像大小完全相同,井的位置不变。在几个小时内拍摄了数百张这个盘子的照片

到目前为止,我已经分割和阈值,但这会导致原始图像强度的损失。 以下是上面发布的原始图像的属性:

print(fo)
Image 
  colorMode    : Color 
  storage.mode : double 
  dim          : 696 520 3 
  frames.total : 3 
  frames.render: 1 

imageData(object)[1:5,1:6,1]
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    0    0    0    0    0    0
[2,]    0    0    0    0    0    0
[3,]    0    0    0    0    0    0
[4,]    0    0    0    0    0    0
[5,]    0    0    0    0    0    0

###迄今为止的进展
图书馆(tidyverse)
图书馆(“电子图像”)
#读入图像

fo这很棘手。让我们首先通过直接从堆栈溢出页面读取图像来复制数据:

库(tidyverse)
图书馆(“电子图像”)

这太棒了,谢谢你。我可能还有更多的问题要问,但我将公布构建分析管道的进展情况,以防对其他人有所帮助。
###progress so far

library(tidyverse)
library("EBImage")

#read in image
fo <- readImage("image.png")

#crop excess
fo <-  fo[99:589,79:437,1:3]

#adaptive thresholding 
threshold <- thresh(fo,w=25,h=25,offset=0.01)

#use bwlabel to segment thresholded image
fo_lab <- bwlabel(threshold[,,2])

nmask = watershed(distmap(threshold), 10 )
display(colorLabels(nmask), all=TRUE)

fo_table <- table(fo_lab)
fo_lab[fo_lab %in% as.numeric(names(fo_table)[fo_table < 100])] <- 0
fo_wells <- as.numeric(names(table(fo_lab)))[-1]
length(fo_wells)
#> [1] 81
df <- as.data.frame(computeFeatures.moment(fo_lab))
df$intensity <- sapply(fo_wells, function(x) mean(fo[fo_lab == x]))
head(df)
#>       m.cx     m.cy m.majoraxis m.eccentricity    m.theta intensity
#> 1 462.2866 17.76579    29.69468      0.3301601 -0.2989824 0.1229826
#> 2 372.9313 20.51608    29.70871      0.1563481 -1.0673974 0.2202901
#> 3 417.3410 19.64526    29.43567      0.2725219  0.4858422 0.1767944
#> 4 328.2435 21.87536    29.73790      0.1112710 -0.9316834 0.3010003
#> 5 283.9245 22.69954    29.17318      0.2366731 -1.4561670 0.5471162
#> 6 239.0390 24.15465    29.39590      0.1881874  0.6315008 0.3799093

img_df <- reshape2::melt(as.matrix(as.raster(as.array(fo))))

ggplot(img_df, aes(Var1, Var2, fill = value)) + 
  geom_raster() +
  scale_fill_identity() +
  scale_y_reverse() +
  geom_text(inherit.aes = FALSE, data = df, color = "red",
            aes(x = m.cx, y = m.cy, label = round(intensity, 3))) +
  coord_equal()