A Homage to Shetland Wool Week

My first foray into colour-work knitting was through Shetland Wool Week. Shetland Wool Week is a week long event celebrating Britain’s most northerly native sheep, the Shetland textile industry and the rural farming community.

Each year a designer creates a knitting pattern for a hat for the week. They are wonderful designs and a great way of connecting knitters around the world. You never know where you’ll meet a Shetland Wool Weeker!

**Shetland Wool Week Hats.** Illustration by [Cathryn Worrell](https://cathrynworrell.com/blog/2019/09/06/shetland-wool-week-hats). Patterns by designers, [Olive Henry](https://olivershetlandwoolblog.home.blog/), [Elizabeth Johnston](http://www.shetlandhandspun.com/), [Gudrun Johnston](https://www.instagram.com/gudrunjohnston/), [Ella Gordon](https://ellagordondesigns.co.uk/), [Donna Smith](https://www.donnasmithdesigns.co.uk/), and [Hazel Tindall](https://www.hazeltindall.com/)

Shetland Wool Week Hats. Illustration by Cathryn Worrell. Patterns by designers, Olive Henry, Elizabeth Johnston, Gudrun Johnston, Ella Gordon, Donna Smith, and Hazel Tindall

The Bousta Beanie

My first ever colour-work project was knitting Gudrun Johnston’s Bousta Beanie hat. It’s been a real delight this year to revisit the pattern as my wedding present to two friends, Julianna and Tom, who were married this Spring.

**My trusty Bousta Beanie.** Pattern by Gudrun Johnston

My trusty Bousta Beanie. Pattern by Gudrun Johnston

I knit the pattern using Jamieson’s of Shetland 2-ply yarn. My friends were excited and a little overwhelmend by all the possible color combinations they could choose!

Introducing Swatch-Creator

As a Professor of Computer Science at College of the Atlantic in Bar Harbor, Maine. I knew there was a way that I could help them choose the colours for their hat using coding and a bit of webscraping! And thus, swatch-creator was born as a way to choose and try out different colors for patterns.

To do this I scraped the photos of the yarns from the Jamieson’s website. I then set about extracting the colors.

# Function to count the colours (adapted from Jeroen Ooms and Matt Dray: https://www.rostrum.blog/2018/11/25/art-of-the-possible/)


get_top_color_blend <- function(image_path) {
  image_i <- image_read(image_path)
  img <- image_convolve(image_i, 'Gaussian:0x5', scaling = '60,20%')
  top_hex <- image_data(img) %>%
    apply(2:3, paste, collapse = "") %>% 
    as.vector %>% table() %>%  as.data.frame() %>% 
    setNames(c("hex", "freq")) %>%
    mutate(hex = paste("#", hex, sep="")) %>%
    slice_max(order_by = freq, n = 1) %>%
    pull(hex)
  
  return(top_hex) # Keep researching to eplace with average
}

get_top_color <- function(image_path) {
  img <- image_read(image_path)
  top_hex <- image_data(img) %>%
    apply(2:3, paste, collapse = "") %>% 
    as.vector %>% table() %>%  as.data.frame() %>% 
    setNames(c("hex", "freq")) %>%
    mutate(hex = paste("#", hex, sep="")) %>%
    slice_max(order_by = freq, n = 3) %>%
    pull(hex)
  
  return(top_hex[3]) #
}

get_top3_color <- function(image_path) {
  img <- image_read(image_path)
  top_hex <- image_data(img) %>%
    apply(2:3, paste, collapse = "") %>% 
    as.vector %>% table() %>%  as.data.frame() %>% 
    setNames(c("hex", "freq")) %>%
    mutate(hex = paste("#", hex, sep="")) %>%
    slice_max(order_by = freq, n = 3) %>%
    pull(hex)
  
  return(top_hex[3]) #
}

I tried a few different methods, either averaging the colours in the image, or picking out the most dominant or second-most dominant colors. I was able to do a good job matching some of the colors, but struggled with the yarns which have lots of beautiful specks in the yarn. Another challenge was the shadowing in some of the pictures, in which case the second-most dominant color was a better match. I’ll continue tinkering with this part of the code to match the colors better.

Creating the swatch

For their hats my friends chose the following colours:

  • Julianna: Loganberry, mirage, and eesit/white.
  • Tom: Purple heather, scotch broom, and eesit/white.

Swatches

Julianna

Tom 1

Tom 2