library(tidyverse)
library(magick)
image_read("fig/color-health-test.jpg") %>%
test_img <- image_resize("30%")
test_img %>%
top_img <- image_crop(geometry = "320x95+10+60")
test_img %>%
bottom_img <- image_crop(geometry = "320x95+10+190")
top_img %>%
first_img <- image_crop(geometry = "110x95")
top_img %>%
second_img <- image_crop(geometry = "110x95+100")
top_img %>%
third_img <- image_crop(geometry = "110x95+200")
bottom_img %>%
forth_img <- image_crop(geometry = "110x95")
bottom_img %>%
fifth_img <- image_crop(geometry = "110x95+100")
bottom_img %>%
sixth_img <- image_crop(geometry = "110x95+210")
list(first_img, second_img, third_img, forth_img, fifth_img,
img_list <-
sixth_img)
map(img_list, image_fill, color = "white", refcolor = "#0E0E0E",
img_bg_list <-fuzz = 10)
function(image){
count_colors <- image_data(image) %>%
data <- apply(2:3, paste, collapse= "") %>%
as.vector %>% table() %>% as.data.frame() %>%
setNames(c("col", "freq"))
$col <- paste("#",data$col, sep="")
datareturn(data)
}
function(data){
plot_hist <- image_graph(500, 500)
img <- ggplot2::ggplot(data) +
plot <- geom_bar(aes(col, freq, fill = I(col)), stat = 'identity') +
theme(axis.title = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank())
print(plot)
dev.off()
img
}
first_img %>%
hist_img <- image_quantize(6, colorspace = 'YCbCr') %>%
count_colors() %>%
plot_hist() %>%
image_resize("300x150")
image_append(c(first_img %>% image_resize("300x150"), hist_img))
function(input_image) {
analyze_image <-
input_image %>%
hist_img <- image_quantize(6, colorspace = 'YCbCr') %>%
count_colors() %>%
plot_hist() %>%
image_resize("300x150")
image_append(c(input_image %>% image_resize("300x150"), hist_img))
}
map(img_bg_list, analyze_image)
hist_img_list <-
%>%
hist_img_list image_join() %>%
image_animate(fps = 0.5)
bottom_img %>%
fifth_img <- image_crop(geometry = "110x95+100")
fifth_img %>%
fifth_bg_img <- image_fill(color = "white", refcolor = "#0E0E0E",
fuzz = 30) %>%
image_transparent(color = "white")
%>%
fifth_bg_img image_quantize(6, colorspace = 'YCbCr') %>%
count_colors() %>%
plot_hist()
%>%
bottom_img image_crop(geometry = "110x95+100") %>%
image_fill(color = "black", refcolor = "#00870000",
fuzz = 10)
bottom_img %>%
color_freq <- image_crop(geometry = "95x95+115+5") %>%
image_quantize(10) %>%
count_colors()
color_freq
col freq
1 #1b1207 2682
2 #977b3e 106
3 #b09450 55
4 #cfae5a 128
5 #debf59 396
6 #eeb933 244
7 #fcc00f 4939
%>%
bottom_img image_crop(geometry = "95x95+115+5") %>%
image_quantize(10) %>%
image_fill(color = "blue", refcolor = "#977b3e", fuzz = 35) %>%
image_fill(color = "blue", refcolor = "#977b3e", fuzz = 35) %>%
image_fill(color = "blue", refcolor = "#cfae5a", fuzz = 35) %>%
image_fill(color = "blue", refcolor = "#debf59", fuzz = 35) %>%
image_fill(color = "blue", refcolor = "#eeb933", fuzz = 35)
데이터 과학자 이광춘 저작
kwangchun.lee.7@gmail.com