-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
71 lines (70 loc) · 4.11 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# using plotly and magick to provide some dust-cleaning functions
library(shiny)
library(magick)
## ui.R
ui <- fluidPage(
shinyjs::useShinyjs(),
titlePanel("Photo Duster", windowTitle = "Photo Duster"),
verticalLayout(
inputPanel(
sliderInput("trim", "Edge crop strength", min = 0, max = 50,
value = 25),
# for radius, there are really only discrete options,
# see https://imagemagick.org/Usage/morphology/#disk
selectInput("k_radius", "Detection Radius",
choices = c(1, 1.5, 2.0, 2.5, 2.9, 3.5, 3.9, 4.3, 4.5, 5.3),
selected = 2.9, width = "50%"),
sliderInput("threshold", "Detection Threshold", min = 1, max = 25,
value = 19, post = "%", step = 1.0),
sliderInput("md_radius", "Replacement Radius", min = 2, max = 15,
value = 8, post = "px"),
sliderInput("f_radius", "Fatten dust", min = 1, max = 10,
value = 1.5, post = "px", step = 0.1),
actionButton("reset", "Reset")
),
tabsetPanel(type = "tabs",
tabPanel("Single",
inputPanel(
fileInput("file1", "Upload image file", accept = c(".jpg", ".png", ".tif")),
# checkboxInput("showDust", "Show dust", TRUE),
checkboxInput("showOriginal", "Show original", FALSE),
sliderInput("zoom", "Image Zoom", min = 1, max = 400,
value = 100, post = "%", step = 10),
selectInput("download_type", "Download file type",
choices = c("jpg", "png", "tif"),
selected = "jpg",
width = "50%"),
downloadButton("download", "Download dusted image")
),
fluidRow(
shinydashboard::box(width = 6,
style='overflow-x: scroll;height:400px;overflow-y: scroll;',
plotOutput("p1") |>
shinycssloaders::withSpinner(color="blue")
),
shinydashboard::box(width = 6,
style='overflow-x: scroll;height:400px;overflow-y: scroll;',
plotOutput("pd") |>
shinycssloaders::withSpinner(color="blue")
)),
conditionalPanel(
condition = "input.showOriginal",
titlePanel("Original:"),
shinydashboard::box(width = 12,
style='overflow-x: scroll;height:400px;overflow-y: scroll;',
plotOutput("p0"))
)
),
tabPanel("Instructions",
strong("How to use the single-image tool."),
p("1. Upload a jpeg. It will be shown, together with the dust detected using the default settings."),
p("2. If there is a 'black' border, it will be mostly removed. If too much is being removed, reduce the edge crop strength."),
p("3. Check the dust. If not enough is being found, increase the detection radius or reduce the detection threshold. It's likely that some larger pieces will escape"),
p("4. Check the dust again. If it is showing real structure from the image (eg mouth, fabric texture), increase the detection threshold."),
p("5. When you're happy, download the image to your browser's default download folder."),
p("Reset: returns to default values."),
div(),
p("For more details and licensing, see ", a(href = "https://github.com/david6marsh/duster", "the github page."))
)
))
)