What Does the AVERAGE Brand Logo Look Like?

October 23, 2015
By

(This article was first published on You Know, and kindly contributed to R-bloggers)

PNG images are essentially a grid of values that represent colors to display. Since each cell in the grid is made up of numbers, I got curious about what it might mean to aggregate multiple PNGs. What would it look like to average two or more images? Median?

To do so, I pulled the top 100 brands’ logos from Best Global Brands.
Then I used the (layers of) values as inputs to aggregate in various ways.

Averaging these logos yields this gray blob that looks roughly, well, saturnine.

 Taking the median value results in what looks like a messy paintbrush stroke.

Clearly, there is quite the uniformity in the logo design. Both horizontal and vertical symmetry are present. There is a bias towards a wider shape, similar to the dimensions of a word. Also, three general shapes tend to appear:  a perfect square, a perfect circle, and the long rectangle.

Is there one agency that designed most of these? They have so much in common.

Below is the R code. It is long because it reflects the evolution of my thought process. A dash of apply could speed up the explicit naming.

   
# Prepare -----------------------------------------------------------------
rm(list=ls())
gc()
pkg <- c("RCurl","XML","png","ggplot2","grid")
inst <- pkg %in% installed.packages()
if(length(pkg[!inst]) > 0) install.packages(pkg[!inst])
lapply(pkg,library,character.only=TRUE)
rm(inst,pkg)
setwd("C:\Users\ddunn\Dropbox\DD Cloud\R\Logos")
set.seed(4444)


# Download HTML -----------------------------------------------------------
url <- "http://www.bestglobalbrands.com/2014/ranking"
if(!exists("html")) {html <- getURL(url)}


# Parse HTML for image sources and info ----------------------------------
doc <- htmlParse(html,asText=TRUE)
plain.src <- xpathApply(doc,"//img[@class='logo-img']",xmlGetAttr,"src")
plain.alt <- xpathApply(doc,"//img[@class='logo-img']",xmlGetAttr,"alt")
plain.brand <- xpathApply(doc,"//div[@class='brand-info brand-name brand-col-4']",
xmlGetAttr,"title")
plain.region <- xpathApply(doc,"//div[@class='brand-info brand-region']",
xmlGetAttr,"title")
plain.country <- xpathApply(doc,"//div[@class='brand-info brand-country brand-col-5']",
xmlGetAttr,"title")
plain.sector <- xpathApply(doc,"//div[@class='brand-info brand-sector brand-col-6']",
xmlGetAttr,"title")
plain.value <- xpathApply(doc,"//div[@class='brand-info brand-value brand-col-7']",
xmlGetAttr,"title")
plain.change <- xpathApply(doc,"//div[@class='brand-info brand-value-change brand-col-8']",
xmlGetAttr,"title")


# Compile info ------------------------------------------------------------
d1 <- data.frame(Brand=unlist(plain.brand),
Country=unlist(plain.country),
Region=unlist(plain.region),
Sector=unlist(plain.sector),
Value=unlist(plain.value),
Change=unlist(plain.change))
d1$Brand <- gsub("Brand name: ","",d1$Brand)
d1$Country <- gsub("Country: ","",d1$Country)
d1$Region <- gsub("Region: ","",d1$Region)
d1$Sector <- gsub("Sector: ","",d1$Sector)
d1$Value <- gsub("Value: ","",d1$Value)
d1$Value <- gsub("[^0-9]","",d1$Value)
d1$Value <- as.numeric(d1$Value)*1000000
d1$Change <- gsub("Change in brand value: ","",d1$Change)
d1$Change <- gsub("\+","",d1$Change)
d1$Change <- gsub("\%","",d1$Change)
d1$Change <- as.numeric(d1$Change)/100


# Clean up foreign characters ---------------------------------------------
Encoding(d1$Brand) <- "UTF-8"


# Download images ---------------------------------------------------------
for(i in 1:length(plain.src)) {
if(!file.exists(paste0(d1$Brand[i],".png"))) {
download.file(plain.src[[i]],destfile=paste0(d1$Brand[i],".png"),mode="wb")
Sys.sleep(1)
}
}


# Read in logo PNGs -------------------------------------------------------
for(i in 1:nrow(d1)) {
assign(paste0(d1$Brand[i]),readPNG(paste0(d1$Brand[i],".png")))
}


# Create object with all zero values --------------------------------------
logo.zero <- Google
for(r in 1:dim(Google)[1]) {
for(c in 1:dim(Google)[2]) {
for(s in 1:dim(Google)[3]) {
logo.zero[r,c,s] <- 0.1
}
}
}


# Average all logos ------------------------------------------------------
logo.avg <- logo.zero
for(r in 1:dim(logo.zero)[1]) {
for(c in 1:dim(logo.zero)[2]) {
for(s in 1:dim(logo.zero)[3]) {
logo.avg[r,c,s] <- sum(`Google`[r,c,s],
`Coca-Cola`[r,c,s],
`IBM`[r,c,s],
`Microsoft`[r,c,s],
`GE`[r,c,s],
`Samsung`[r,c,s],
`Toyota`[r,c,s],
`McDonald's`[r,c,s],
`Mercedes-Benz`[r,c,s],
`BMW`[r,c,s],
`Intel`[r,c,s],
`Disney`[r,c,s],
`Cisco`[r,c,s],
`Amazon`[r,c,s],
`Oracle`[r,c,s],
`HP`[r,c,s],
`Gillette`[r,c,s],
`Louis Vuitton`[r,c,s],
`Honda`[r,c,s],
`H&M`[r,c,s],
`Nike`[r,c,s],
`American Express`[r,c,s],
`Pepsi`[r,c,s],
`SAP`[r,c,s],
`IKEA`[r,c,s],
`UPS`[r,c,s],
`eBay`[r,c,s],
`Facebook`[r,c,s],
`Pampers`[r,c,s],
`Volkswagen`[r,c,s],
`Kellogg's`[r,c,s],
`HSBC`[r,c,s],
`Budweiser`[r,c,s],
`J.P. Morgan`[r,c,s],
`Zara`[r,c,s],
`Canon`[r,c,s],
`Nescafé`[r,c,s],
`Ford`[r,c,s],
`Hyundai`[r,c,s],
`Gucci`[r,c,s],
`Philips`[r,c,s],
`L’Oréal`[r,c,s],
`Accenture`[r,c,s],
`Audi`[r,c,s],
`Hermès`[r,c,s],
`Goldman Sachs`[r,c,s],
`Citi`[r,c,s],
`Siemens`[r,c,s],
`Colgate`[r,c,s],
`Danone`[r,c,s],
`Sony`[r,c,s],
`AXA`[r,c,s],
`Nestlé`[r,c,s],
`Allianz`[r,c,s],
`Nissan`[r,c,s],
`Thomson Reuters`[r,c,s],
`Cartier`[r,c,s],
`adidas`[r,c,s],
`Porsche`[r,c,s],
`Caterpillar`[r,c,s],
`Xerox`[r,c,s],
`Morgan Stanley`[r,c,s],
`Panasonic`[r,c,s],
`Shell`[r,c,s],
`3M`[r,c,s],
`Discovery`[r,c,s],
`KFC`[r,c,s],
`Visa`[r,c,s],
`Prada`[r,c,s],
`Tiffany & Co.`[r,c,s],
`Sprite`[r,c,s],
`Burberry`[r,c,s],
`Kia`[r,c,s],
`Santander`[r,c,s],
`Starbucks`[r,c,s],
`Adobe`[r,c,s],
`Johnson & Johnson`[r,c,s],
`John Deere`[r,c,s],
`MTV`[r,c,s],
`DHL`[r,c,s],
`Chevrolet`[r,c,s],
`Ralph Lauren`[r,c,s],
`Duracell`[r,c,s],
`Jack Daniel's`[r,c,s],
`Johnnie Walker`[r,c,s],
`Harley-Davidson`[r,c,s],
`MasterCard`[r,c,s],
`Kleenex`[r,c,s],
`Smirnoff`[r,c,s],
`Land Rover`[r,c,s],
`FedEx`[r,c,s],
`Corona`[r,c,s],
`Huawei`[r,c,s],
`Heineken`[r,c,s],
`Pizza Hut`[r,c,s],
`Hugo Boss`[r,c,s],
`Nokia`[r,c,s],
`Gap`[r,c,s],
`Nintendo`[r,c,s]) / length(d1$Brand)
}
}
}

dev.off()
grid.raster(logo.avg)


# Median all logos- ------------------------------------------------------
logo.med <- logo.zero
for(r in 1:dim(logo.zero)[1]) {
for(c in 1:dim(logo.zero)[2]) {
for(s in 1:dim(logo.zero)[3]) {
logo.med[r,c,s] <- median(c(`Google`[r,c,s],
`Coca-Cola`[r,c,s],
`IBM`[r,c,s],
`Microsoft`[r,c,s],
`GE`[r,c,s],
`Samsung`[r,c,s],
`Toyota`[r,c,s],
`McDonald's`[r,c,s],
`Mercedes-Benz`[r,c,s],
`BMW`[r,c,s],
`Intel`[r,c,s],
`Disney`[r,c,s],
`Cisco`[r,c,s],
`Amazon`[r,c,s],
`Oracle`[r,c,s],
`HP`[r,c,s],
`Gillette`[r,c,s],
`Louis Vuitton`[r,c,s],
`Honda`[r,c,s],
`H&M`[r,c,s],
`Nike`[r,c,s],
`American Express`[r,c,s],
`Pepsi`[r,c,s],
`SAP`[r,c,s],
`IKEA`[r,c,s],
`UPS`[r,c,s],
`eBay`[r,c,s],
`Facebook`[r,c,s],
`Pampers`[r,c,s],
`Volkswagen`[r,c,s],
`Kellogg's`[r,c,s],
`HSBC`[r,c,s],
`Budweiser`[r,c,s],
`J.P. Morgan`[r,c,s],
`Zara`[r,c,s],
`Canon`[r,c,s],
`Nescafé`[r,c,s],
`Ford`[r,c,s],
`Hyundai`[r,c,s],
`Gucci`[r,c,s],
`Philips`[r,c,s],
`L’Oréal`[r,c,s],
`Accenture`[r,c,s],
`Audi`[r,c,s],
`Hermès`[r,c,s],
`Goldman Sachs`[r,c,s],
`Citi`[r,c,s],
`Siemens`[r,c,s],
`Colgate`[r,c,s],
`Danone`[r,c,s],
`Sony`[r,c,s],
`AXA`[r,c,s],
`Nestlé`[r,c,s],
`Allianz`[r,c,s],
`Nissan`[r,c,s],
`Thomson Reuters`[r,c,s],
`Cartier`[r,c,s],
`adidas`[r,c,s],
`Porsche`[r,c,s],
`Caterpillar`[r,c,s],
`Xerox`[r,c,s],
`Morgan Stanley`[r,c,s],
`Panasonic`[r,c,s],
`Shell`[r,c,s],
`3M`[r,c,s],
`Discovery`[r,c,s],
`KFC`[r,c,s],
`Visa`[r,c,s],
`Prada`[r,c,s],
`Tiffany & Co.`[r,c,s],
`Sprite`[r,c,s],
`Burberry`[r,c,s],
`Kia`[r,c,s],
`Santander`[r,c,s],
`Starbucks`[r,c,s],
`Adobe`[r,c,s],
`Johnson & Johnson`[r,c,s],
`John Deere`[r,c,s],
`MTV`[r,c,s],
`DHL`[r,c,s],
`Chevrolet`[r,c,s],
`Ralph Lauren`[r,c,s],
`Duracell`[r,c,s],
`Jack Daniel's`[r,c,s],
`Johnnie Walker`[r,c,s],
`Harley-Davidson`[r,c,s],
`MasterCard`[r,c,s],
`Kleenex`[r,c,s],
`Smirnoff`[r,c,s],
`Land Rover`[r,c,s],
`FedEx`[r,c,s],
`Corona`[r,c,s],
`Huawei`[r,c,s],
`Heineken`[r,c,s],
`Pizza Hut`[r,c,s],
`Hugo Boss`[r,c,s],
`Nokia`[r,c,s],
`Gap`[r,c,s],
`Nintendo`[r,c,s]))
}
}
}

dev.off()
grid.raster(logo.med)


# Create mode function ----------------------------------------------------
Mode <- function(x) {
ux <- unique(x)
ux[which.max(tabulate(match(x,ux)))]
}


# Mode all logos- --------------------------------------------------------
logo.mod <- logo.zero
for(r in 1:dim(logo.zero)[1]) {
for(c in 1:dim(logo.zero)[2]) {
for(s in 1:dim(logo.zero)[3]) {
logo.mod[r,c,s] <- Mode(c(`Google`[r,c,s],
`Coca-Cola`[r,c,s],
`IBM`[r,c,s],
`Microsoft`[r,c,s],
`GE`[r,c,s],
`Samsung`[r,c,s],
`Toyota`[r,c,s],
`McDonald's`[r,c,s],
`Mercedes-Benz`[r,c,s],
`BMW`[r,c,s],
`Intel`[r,c,s],
`Disney`[r,c,s],
`Cisco`[r,c,s],
`Amazon`[r,c,s],
`Oracle`[r,c,s],
`HP`[r,c,s],
`Gillette`[r,c,s],
`Louis Vuitton`[r,c,s],
`Honda`[r,c,s],
`H&M`[r,c,s],
`Nike`[r,c,s],
`American Express`[r,c,s],
`Pepsi`[r,c,s],
`SAP`[r,c,s],
`IKEA`[r,c,s],
`UPS`[r,c,s],
`eBay`[r,c,s],
`Facebook`[r,c,s],
`Pampers`[r,c,s],
`Volkswagen`[r,c,s],
`Kellogg's`[r,c,s],
`HSBC`[r,c,s],
`Budweiser`[r,c,s],
`J.P. Morgan`[r,c,s],
`Zara`[r,c,s],
`Canon`[r,c,s],
`Nescafé`[r,c,s],
`Ford`[r,c,s],
`Hyundai`[r,c,s],
`Gucci`[r,c,s],
`Philips`[r,c,s],
`L’Oréal`[r,c,s],
`Accenture`[r,c,s],
`Audi`[r,c,s],
`Hermès`[r,c,s],
`Goldman Sachs`[r,c,s],
`Citi`[r,c,s],
`Siemens`[r,c,s],
`Colgate`[r,c,s],
`Danone`[r,c,s],
`Sony`[r,c,s],
`AXA`[r,c,s],
`Nestlé`[r,c,s],
`Allianz`[r,c,s],
`Nissan`[r,c,s],
`Thomson Reuters`[r,c,s],
`Cartier`[r,c,s],
`adidas`[r,c,s],
`Porsche`[r,c,s],
`Caterpillar`[r,c,s],
`Xerox`[r,c,s],
`Morgan Stanley`[r,c,s],
`Panasonic`[r,c,s],
`Shell`[r,c,s],
`3M`[r,c,s],
`Discovery`[r,c,s],
`KFC`[r,c,s],
`Visa`[r,c,s],
`Prada`[r,c,s],
`Tiffany & Co.`[r,c,s],
`Sprite`[r,c,s],
`Burberry`[r,c,s],
`Kia`[r,c,s],
`Santander`[r,c,s],
`Starbucks`[r,c,s],
`Adobe`[r,c,s],
`Johnson & Johnson`[r,c,s],
`John Deere`[r,c,s],
`MTV`[r,c,s],
`DHL`[r,c,s],
`Chevrolet`[r,c,s],
`Ralph Lauren`[r,c,s],
`Duracell`[r,c,s],
`Jack Daniel's`[r,c,s],
`Johnnie Walker`[r,c,s],
`Harley-Davidson`[r,c,s],
`MasterCard`[r,c,s],
`Kleenex`[r,c,s],
`Smirnoff`[r,c,s],
`Land Rover`[r,c,s],
`FedEx`[r,c,s],
`Corona`[r,c,s],
`Huawei`[r,c,s],
`Heineken`[r,c,s],
`Pizza Hut`[r,c,s],
`Hugo Boss`[r,c,s],
`Nokia`[r,c,s],
`Gap`[r,c,s],
`Nintendo`[r,c,s]))
}
}
}

dev.off()
grid.raster(logo.mod)


# Random pick all logos- ----------------------------------------------------
logo.ran <- logo.zero
for(r in 1:dim(logo.zero)[1]) {
for(c in 1:dim(logo.zero)[2]) {
for(s in 1:dim(logo.zero)[3]) {
logo.ran[r,c,s] <- sample(c(`Google`[r,c,s],
`Coca-Cola`[r,c,s],
`IBM`[r,c,s],
`Microsoft`[r,c,s],
`GE`[r,c,s],
`Samsung`[r,c,s],
`Toyota`[r,c,s],
`McDonald's`[r,c,s],
`Mercedes-Benz`[r,c,s],
`BMW`[r,c,s],
`Intel`[r,c,s],
`Disney`[r,c,s],
`Cisco`[r,c,s],
`Amazon`[r,c,s],
`Oracle`[r,c,s],
`HP`[r,c,s],
`Gillette`[r,c,s],
`Louis Vuitton`[r,c,s],
`Honda`[r,c,s],
`H&M`[r,c,s],
`Nike`[r,c,s],
`American Express`[r,c,s],
`Pepsi`[r,c,s],
`SAP`[r,c,s],
`IKEA`[r,c,s],
`UPS`[r,c,s],
`eBay`[r,c,s],
`Facebook`[r,c,s],
`Pampers`[r,c,s],
`Volkswagen`[r,c,s],
`Kellogg's`[r,c,s],
`HSBC`[r,c,s],
`Budweiser`[r,c,s],
`J.P. Morgan`[r,c,s],
`Zara`[r,c,s],
`Canon`[r,c,s],
`Nescafé`[r,c,s],
`Ford`[r,c,s],
`Hyundai`[r,c,s],
`Gucci`[r,c,s],
`Philips`[r,c,s],
`L’Oréal`[r,c,s],
`Accenture`[r,c,s],
`Audi`[r,c,s],
`Hermès`[r,c,s],
`Goldman Sachs`[r,c,s],
`Citi`[r,c,s],
`Siemens`[r,c,s],
`Colgate`[r,c,s],
`Danone`[r,c,s],
`Sony`[r,c,s],
`AXA`[r,c,s],
`Nestlé`[r,c,s],
`Allianz`[r,c,s],
`Nissan`[r,c,s],
`Thomson Reuters`[r,c,s],
`Cartier`[r,c,s],
`adidas`[r,c,s],
`Porsche`[r,c,s],
`Caterpillar`[r,c,s],
`Xerox`[r,c,s],
`Morgan Stanley`[r,c,s],
`Panasonic`[r,c,s],
`Shell`[r,c,s],
`3M`[r,c,s],
`Discovery`[r,c,s],
`KFC`[r,c,s],
`Visa`[r,c,s],
`Prada`[r,c,s],
`Tiffany & Co.`[r,c,s],
`Sprite`[r,c,s],
`Burberry`[r,c,s],
`Kia`[r,c,s],
`Santander`[r,c,s],
`Starbucks`[r,c,s],
`Adobe`[r,c,s],
`Johnson & Johnson`[r,c,s],
`John Deere`[r,c,s],
`MTV`[r,c,s],
`DHL`[r,c,s],
`Chevrolet`[r,c,s],
`Ralph Lauren`[r,c,s],
`Duracell`[r,c,s],
`Jack Daniel's`[r,c,s],
`Johnnie Walker`[r,c,s],
`Harley-Davidson`[r,c,s],
`MasterCard`[r,c,s],
`Kleenex`[r,c,s],
`Smirnoff`[r,c,s],
`Land Rover`[r,c,s],
`FedEx`[r,c,s],
`Corona`[r,c,s],
`Huawei`[r,c,s],
`Heineken`[r,c,s],
`Pizza Hut`[r,c,s],
`Hugo Boss`[r,c,s],
`Nokia`[r,c,s],
`Gap`[r,c,s],
`Nintendo`[r,c,s]),1)
}
}
}

dev.off()
grid.raster(logo.ran)


To leave a comment for the author, please follow the link and comment on their blog: You Know.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)