Can square tree rings be generated from primes? Apparently yes! In three easy steps.
Step 1
Let f(n) denote the prime-counting function (number of primes less than or equal to n).
Define the integer sequence s(n) as follows. For each positive integer n,

Initiallize t to n.
As long as t is neither prime nor 1, replace t by f(t) and iterate.
The number of iterations is s(n).

The iterative process is guaranteed to end because f(n) &lt; n for all n.
Consider for example n=25. We initiallize t = 25. Since this is not a prime nor 1, we compute f(25), which is 9. This becomes the new value for t. This is not a prime nor 1, so we continue: f(9) is 4. We continue again: f(4) is 2. Since this is a prime we stop here. We have done 3 iterations (from 25 to 9, then to 4, then to 2). Thus s(25) is 3.
The first 40 terms of the sequence are as follows. The sequence is not in OEIS.
0 0 0 1 0 1 0 2 2 2 0 1 0 2 2 2 0 1 0 3 3 3 0 3 3 3 3 3 0 3 0 1 1 1 1 1 0 2 2 2

Step 2
Given an odd positive integer N, build an N×N array (matrix) by winding the finite sequence s(1), s(2), ..., s(N2) to form a square outward spiral. For example, given N = 5 the spiral is
s(21)   s(22)   s(23)   s(24)   s(25)
s(20)   s(7)    s(8)    s(9)    s(10)
s(19)   s(6)    s(1)    s(2)    s(11)
s(18)   s(5)    s(4)    s(3)    s(12)
s(17)   s(16)   s(15)   s(14)   s(13)

or, substituting the values,
 3       3       0       3       3
 3       0       2       2       2
 0       1       0       0       0
 1       0       1       0       1
 0       2       2       2       0

Step 3
Represent the N×N array as an image with a grey colour map, or with some other colour map of your taste. The map should be gradual, so that the order of numbers corresponds to some visually obvious order of the colours. The test cases below show some example colour maps.
The challenge
Given an odd positive integer N, produce the image described above.
Rules

The spiral must be outward, but can be clockwise or counter-clockwise, and can start moving right (as in the above example), left, down or up.

The scales of the horizontal and vertical axes need not be the same. Also axis labels, colorbar and similar elements are optional. As long as the spiral can be clearly seen, the image is valid.

Images can be output by any of the standard means. In particular, the image may be displayed on screen, or a graphics file may be produced, or an array of RGB values may be output. If outputting a file or an array, please post an example of what it looks like when displayed.

Input means and format are flexible as usual. A program or a function can be provided. Standard loopholes are forbidden.

Shortest code in bytes wins.


Test cases
The following images (click for full resolution) correspond to several values of N. A clock-wise, rightward-first spiral is used, as in the example above. The images also illustrate several valid colour maps.

N = 301:


N = 501:


N = 701:
MATLAB - 197 185 178 175 184 163 162 148 142 140 bytes

Shaved 12 bytes, thanks to Ander and Andras, and lots thanks to Luis for putting the two together. Shaved 16 thanks to Remco, 6 thanks to flawr

function F(n)
p=@primes
s=@isprime
for a=2:n^2
c=0
if~s(a)
b=nnz(p(a))
while~s(b)
b=nnz(p(b))
c=c+1
end
end
d(a)=c
end
imagesc(d(spiral(n)))


Result for N=301 (F(301)):



Explanation:

function F(n)
p=@primes % Handle
s=@isprime % Handle
for a=2:n^2 % Loop over all numbers
    c=0 % Set initial count
    if~s(a) % If not a prime
        b=nnz(p(a)) % Count primes
        while~s(b) % Stop if b is a prime. Since the code starts at 2, it never reaches 1 anyway
            b=nnz(p(b)) % count again
            c=c+1 % increase count
        end
    end
    d(a)=c % store count
end
imagesc(d(spiral(n))) % plot