eBimage软件包的显示功能不会在ShinyApps.io中显示交互式图像



我正在为使用R和eBimage软件包的图像分析编程。闪亮的应用程序在本地成功运行。经过一些试验,我想通过ShinyApps.io平台访问应用程序。

在shinyapps.io中,该应用程序呈现图像(静态)显示正确,但不能显示交互式。它仍然空白。

¿一个想法?

谢谢

这是代码:

library("shiny")
library("EBImage")
ui <- fluidPage(
# Application title
titlePanel("Image display"),
# Sidebar with a select input for the image
sidebarLayout(
   sidebarPanel(
     fileInput("image", "Select image")
),
# Show a plot of the generated distribution
mainPanel(
  tabsetPanel(
    tabPanel("Static raster", plotOutput("raster")),
    tabPanel("Interactive browser", displayOutput("widget"))
  )
)
)
)
server <- function(input, output) {
img <- reactive({
f <- input$image
if (is.null(f))
  return(NULL)        
readImage(f$datapath)
})
output$widget <- renderDisplay({
req(img())
display(img())
})
output$raster <- renderPlot({
req(img())
plot(img(), all=FALSE)
})
}
# Run the application
shinyApp(ui = ui, server = server)

我也偶然发现了这个问题。我认为这是由于显示功能设计为从交互式会话中使用的事实引起的。

该修复程序仅在将方法参数添加到显示呼叫中。因此您的代码应该是:

...
output$widget <- renderDisplay({
  req(img())
  display(img(), method = 'browser') # <- this should make the trick
})
...

最新更新