шифровка из центра ... индекс ячейки указать в строке 32
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<table id="t1">
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>5</td></tr>
<tr><td>2</td></tr>
<tr><td>2</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>3</td></tr>
<tr><td>3</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
<tr><td>4</td></tr>
</table>
<script>
(function(i) {
var c = ["red", "green", "blue"], a;
[].forEach.call(document.querySelectorAll("#t1 tr"), function(d, e, b) {
(b = b[++e]) && b.cells[i].textContent == d.cells[i].textContent ?
(a || (a = c.shift()), d.style.backgroundColor = a, b.style.backgroundColor = a) :
a && (c.push(a), a = void 0);
});
})(0);
</script>
</body>
</html>