Finding all possible combination **patterns** - as opposed to all possible combinations I start off with trying to find the number of possible combinations for a 5x5 grid (25 spaces), where each space could be a color from 1-4 (so 1, 2, 3, or 4)
I do 4^25 = 1,125,899,906,842,624 different combinations
However, now I'm trying to change the number of combinations to account for grids with the same number pattern, for example:
{ 1 1 1 1 1 }
{ 3 3 3 3 3 }
{ 4 4 2 2 3 }
{ 4 3 2 1 1 }
{ 2 2 1 2 3 }
1 is now 2, 2 is now 4, 3 is now 1, 4 is now 3

{ 2 2 2 2 2 }
{ 1 1 1 1 1 }
{ 3 3 4 4 1 }
{ 3 1 4 2 2 }
{ 4 4 2 4 1 }
I'm having trouble trying to come up with an equation I can use to solve this for a (x * y) grid where each space could be a color from 1 to (c).
 A: You need to split the count according to the number of different numbers used. There are $4$ grids using one number each, but they all yield the same pattern.
At the other extreme there are
$$4^{25}-\binom43\cdot3^{25}+\binom42\cdot2^{25}-\binom41\cdot1^{25}=4^{25}-4\cdot3^{25}+6\cdot2^{25}-4$$
grids that use all four numbers. The four numbers can be permuted in $4!=24$ different ways, so there are
$$\frac1{24}\left(4^{25}-4\cdot3^{25}+6\cdot2^{25}-4\right)$$
patterns.
Given two colors, say $a$ and $b$, we can fill them into the grid in $2^{25}-2$ ways (since we need to exclude the one-number grids). However, that counts each pattern twice, since we can interchange $a$ and $b$, so this case contributes $2^{24}-1$ patterns.
Similarly, three colors can be filled into the grid in
$$3^{25}-\binom32\cdot2^{25}+\binom31\cdot1^{25}=3^{25}-3\cdot2^{25}+3$$
ways, but the colors can be permuted in $3!=6$ ways, so the number of patterns is only
$$\frac16\left(3^{25}-3\cdot2^{25}+3\right)=\frac12\left(3^{24}-2^{25}+1\right)\;.$$
A: $\sum _{n=1}^c \mathcal{S}_{x y}^{(n)}$ is what you're after, with $x, y, c$ the two dimensions and the number of colors. $\mathcal{S}_{x y}^{(n)}$ is the Stirling number of the second kind. 
This generalizes to arbitrary dimensions.
A: Observation. Note that
$${25\brace 1} + {25\brace 2} + {25\brace 3} + {25\brace 4}
\\= 1 + 2^{24} -1 + \frac{1}{2}(3^{24}-2^{25}+1)
+ \frac{1}{24}(4^{25}-4\times3^{25}+6\times2^{25}-4).$$
A: Assign four colours (a,b,c,d) to the values (1,2,3,4) - how many ways can this be done? $4!=24$ That is the number you need to divide by, for grids that use all four colours, and (I think) for grids that only use three colours. For grids with only one or two colours, the number of options reduces, because switching the unused colours doesn't make any difference. So for example with monochrome grids, instead of $4!=24$ options there are only $\frac{4!}{6}=4$ options (of course). For two-colour grids, there are $\frac{4!}{2}=12$ options to divide out.
