@JadenPan I "stolen" those primes from some of the fastest solutions of "Number of Distinct Islands" which can be seen when you got your solution accepted.

However, they needn't to be primes, but we have to differentiate different aspects of the "Shape" of an island. A better choice may be by observing the row-by-row(column-by-column) fluctuates of heights(width) and finding out the characteristics.

FYI.