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.
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.
Vertical and horizontal stripes of a tartan have the same pattern:
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:
The resulting image will look as follows:
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:
This method was used to produce the following picture:
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:
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]
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%
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.