Tartans

due: Sunday, March 30th at 11:59 PM

Tartan is a traditional Scottish fabric pattern consisting of intersecting horizontal and vertical stripes in various colors. Tartans are a part of the Scottish highland dress.

../../_images/Campbell_of_Breadalbane.png

A lithograph of a member of the Scottish Highland clan of Campbell dressed in the Campbell tartan.

The Scottish Register of Tartans lists thousands of tartan designs that were created for use by various clans, localities, organizations etc.

Making a tartan

Vertical and horizontal stripes of a tartan have the same pattern:

../../_images/warp_weft.png

In order to combine these pictures into an image of a tartan we can use a checkerboard that alternates between showing vertical and horizontal stripes. In the image below, horizontal stripes were given slightly lighter colors to show this pattern more clearly:

../../_images/campbell_sample1.png

The resulting image will look as follows:

../../_images/campbell_sample2.png

A more realistic image of a tartan can be obtained by modifying the way in which vertical and horizontal stripes are combined. Instead of using the checkerboard pattern, each column of pixels shows two pixels of vertical stripes, then two pixels of horizontal stripes and so on. In each subsequent column this pattern gets shifted down by one pixel. In the image below, horizontal stripes were again given slightly lighter colors to show this pattern more clearly:

../../_images/campbell_sample3.png

This method was used to produce the following picture:

../../_images/campbell_sample4.png

Recipe for a tartan

To specify the design of a tartan it suffices to give widths and colors of its vertical stripes. Since horizontal stripes have the same pattern as the vertical ones, there is no need to describe them separately. For example, the pattern of stripes of the Campbell tartan can be described as follows:

B14 K6 B6 K6 B6 K32 OG32 K6 OG32 K32 B32 K6 B6 K6 B32 K32 OG32 K6 OG32 K32 B6 K6 B6 K6 B28

The letter codes B, K, OG indicate different stripe colors, and the number following each letter code is the width of the stripe. In the production of tartan fabrics this number gives the number of threads in the stripe. In computer generated images of tartans we can take it to be the width of the stripe in pixels or some other units. The pattern will repeat to fill an image of an arbitrary size.

To complete the description of a tartan one needs to specify what color each letter code stands for. This can be done e.g. by giving RGB coordinates of each color:

B : [52, 80, 100], K : [16, 16, 16], OG : [92, 100, 40]

Project

The table below lists several tartan patterns. Find the tartan assigned to you and write Python code that produces an image of this tartan. Dimensions of the image must be 500x500 threads, with pattern repeating as many times as needed to fill the whole image.

Note. This is a programming project. Your project report does not need to include narrative, beyond comments explaining how your code works. The project will be graded according to the following rubrics:

  • Reproduction of the assigned tartan (with the more realistic stripe combination): 70%

  • Report organization and code documentation: 30%

Extra credit

Write a function recover_tartan_pattern that takes in an array tartan (with shape (N,N,3)) depicting an authentic tartan pattern. The function should output the “recipe” for the input tartan. You can test this on your own assigned tartan, or the example tartan shown above, or with any of the tartans assigned to your classmates. Note: your function will need some way to give labels to the colors that it finds. This labeling does not need to coincide with the labeling choices made in this page.

../../_images/eliascol.png
Collins, Eli
R4 K2 R56 K48 R2 K12 R2 K48 R56 K2 R4
R : [200, 0, 0]
K : [16, 16, 16]
../../_images/elifelds.png
Feldstein, Eli
B2 K8 B8 G18 K4 G18 B8 K8 B2
B : [44, 44, 128]
K : [16, 16, 16]
G : [0, 104, 24]
../../_images/amritaga.png
Ganapathy, Amrita
T4 W44 T40 LT6 T6 LT6 T6 LT48 T6 LT6 T6 LT6 T40 W44 T4
T : [96, 64, 0]
W : [224, 224, 224]
LT : [160, 136, 88]
../../_images/qmgibbon.png
Gibbons, Quentin
N2 T4 N30 T4 W20 LT30 T4 LT4 T4 LT30 W20 T4 N30 T4 N2
W : [224, 224, 224]
T : [96, 64, 0]
LT : [160, 136, 88]
N : [136, 136, 136]
../../_images/skylagre.png
Greene-Murchison, Skyla
WY5 DY64 AK64 DY10 AK64 DY64 WY5
WY : [224, 224, 224]
AK : [28, 28, 28]
DY : [232, 192, 0]
../../_images/dheredia.png
Heredia Paredes, Diego
C128 B36 C4 B6 C4 B6 C28 L16 C4 L8 C4 L8 C4 L16 C28 B6 C4 B6 C4 B36
L : [40, 136, 196]
B : [32, 32, 96]
C : [160, 0, 72]
../../_images/omarjaff.png
Jaffri, Omar
XR8 A6 DY52 DB8 DY4 DB10 XR6 DB18 DY10 DB18 XR6 DB10 DY4 DB8 DY52 A6
DY : [232, 192, 0]
XR : [200, 0, 0]
DB : [32, 32, 96]
A : [92, 140, 168]
../../_images/alecjens.png
Jensen, Alec
K5 R60 K28 Y2 K28 R10 K28 Y2 K28 R60 K5
R : [220, 0, 0]
Y : [232, 192, 0]
K : [16, 16, 16]
../../_images/jiongliu.png
Liu, Jiong
K8 W8 K64 W64 K8 W64 K64 W8 K8
W : [224, 224, 224]
K : [16, 16, 16]
../../_images/yuleisim.png
Martinez, Yuleisi
YT44 DR6 YT6 DR6 YT6 DR6 YT6 DR6 YT44 FSB3 YT3 G3 YT3 LN3
DR : [136, 0, 0]
LN : [192, 192, 192]
YT : [216, 176, 0]
FSB : [36, 116, 232]
G : [0, 104, 24]
../../_images/ianmcmee.png
McMeekin, Ian
K2 R54 G8 R4 G8 R8 G18 W2 G18 R16 G18 W2 G18 R8 G8 R4 G8 R54 K2
G : [0, 104, 24]
R : [220, 0, 0]
W : [224, 224, 224]
K : [16, 16, 16]
../../_images/asnewbur.png
Newbury, Amanda
R6 K6 LSB14 RY52 K52 WW10 K52 RY52 LSB14 K6
WW : [252, 252, 252]
K : [0, 0, 0]
LSB : [152, 200, 232]
RY : [188, 140, 0]
R : [200, 0, 0]
../../_images/rmortiz2.png
Ortiz, Rebecca
K6 R2 K60 R56 K2 R2 W6 R2 K2 R56 K60 R2 K6
K : [16, 16, 16]
W : [224, 224, 224]
R : [220, 0, 0]
../../_images/cmpretna.png
Pretnar, Carson
O3 Y24 O24 WW6 Y4 FG52 O6 Y2 O6 FG52 Y4 WW6 O24 Y24 O3
WW : [248, 248, 248]
FG : [168, 148, 72]
O : [248, 132, 16]
Y : [232, 192, 0]
../../_images/anrao4.png
Rao, Austin
R4 B24 R8 G24 R48 W8 R48 G24 R8 B24 R4
G : [0, 104, 24]
B : [44, 44, 128]
R : [220, 0, 0]
W : [224, 224, 224]
../../_images/ctrennel.png
Rennells, Christopher
B10 R4 B20 R32 W4 R32 B20 R4 B10
B : [44, 44, 128]
R : [220, 0, 0]
W : [184, 184, 184]
../../_images/gsrich.png
Rich, Gabriella
D50 B4 R50 G20 R8 D50 R4 G4 R50 G4 R4 G4 R50 G4 R4 D50 R8 G20 R50 B4
B : [44, 44, 128]
R : [200, 0, 0]
D : [32, 32, 96]
G : [0, 104, 24]
../../_images/cr226.png
Rodriguez, Cristian
DR3 R6 LN46 R6 DR6 R46 K4 R6 K4 R46 DR6 R6 LN46 R6 DR3
K : [16, 16, 16]
LN : [192, 192, 192]
R : [200, 0, 0]
DR : [136, 0, 0]
../../_images/ryansaab.png
Saab, Ryan
K3 W32 K32 DN4 K4 DN4 K4 DN44 K4 DN4 K4 DN4 K32 W32 K3
DN : [92, 92, 92]
W : [224, 224, 224]
K : [16, 16, 16]
../../_images/ramateja.png
Sambaraju, Teja
B4 LB8 B20 LB20 W4 LB20 B10 LB20 W4 LB20 B20 LB8 B4
LB : [40, 136, 196]
B : [44, 44, 128]
W : [224, 224, 224]
../../_images/rtsaucke.png
Saucke, Raymond
K6 Y4 K42 Y4 K12 Y48 K4 Y12 K4 Y48 K12 Y4 K42 Y4 K6
Y : [232, 192, 0]
K : [16, 16, 16]
../../_images/msmith37.png
Smith, Randi
K16 Y4 K32 Y48 R4 Y48 K32 Y4 K16
K : [16, 16, 16]
Y : [216, 176, 0]
R : [200, 0, 0]
../../_images/xtstanto.png
Stanton, Xavier
A2 K24 A24 B8 R48 A8 R48 B8 A24 K24 A2
A : [60, 130, 175]
B : [44, 64, 132]
R : [220, 0, 0]
K : [16, 16, 16]
../../_images/emilytap.png
Tapia Cajilima, Emily
DG56 W8 DB12 LG28 DG8 LG28 DB12 W8 DG56 A8
W : [224, 224, 224]
DB : [32, 32, 96]
A : [92, 140, 168]
LG : [152, 180, 128]
DG : [0, 56, 32]
../../_images/aevicker.png
Vickery, Drew
Y2 DG48 DB14 DR52 DB14 DR52 DB14 DG48 Y2
DB : [32, 32, 96]
Y : [232, 192, 0]
DG : [0, 56, 32]
DR : [136, 0, 0]
../../_images/sswu2.png
Wu, Sydney
DR4 DB12 G30 BL18 DB60 BL18 G12 MY4 G12 BL18 DB60 BL18 G30 DB12
G : [20, 100, 0]
MY : [200, 140, 0]
BL : [20, 116, 180]
DB : [0, 0, 80]
DR : [140, 0, 0]
../../_images/xichenzh.png
Zhang, Xichen
RB8 MY4 RB24 DR4 RB8 DR8 K8 G24 A4 G8 A4 G24 K8 DR8 RB8 DR4 RB24 MY4
A : [92, 140, 168]
MY : [208, 152, 0]
DR : [136, 0, 0]
G : [0, 104, 24]
RB : [28, 0, 112]
K : [16, 16, 16]
../../_images/azumpano.png
Zumpano, Arianna
B3 K4 T32 O50 B12 O50 T32 K4 B3
B : [44, 44, 128]
K : [16, 16, 16]
T : [96, 64, 0]
O : [216, 124, 0]