We are given the integral:
\[
I = \int_0^1 \left| x - \frac{1}{2} \right| \, dx.
\]
Since \( x - \frac{1}{2} \) changes sign at \( x = \frac{1}{2} \), we split the integral at \( x = \frac{1}{2} \).
Thus, we write:
\[
I = \int_0^{\frac{1}{2}} \left( -x + \frac{1}{2} \right) \, dx + \int_{\frac{1}{2}}^1 \left( x - \frac{1}{2} \right) \, dx.
\]
Step 1: Evaluate the first integral.
For \( 0 \leq x \leq \frac{1}{2} \), \( x - \frac{1}{2} \) is negative, so we have:
\[
\int_0^{\frac{1}{2}} \left( -x + \frac{1}{2} \right) \, dx = \int_0^{\frac{1}{2}} \left( \frac{1}{2} - x \right) \, dx.
\]
Integrating:
\[
\int_0^{\frac{1}{2}} \left( \frac{1}{2} - x \right) \, dx = \left[ \frac{1}{2}x - \frac{x^2}{2} \right]_0^{\frac{1}{2}} = \left( \frac{1}{2} \cdot \frac{1}{2} - \frac{\left( \frac{1}{2} \right)^2}{2} \right) - (0) = \frac{1}{4} - \frac{1}{8} = \frac{1}{8}.
\]
Step 2: Evaluate the second integral.
For \( \frac{1}{2} \leq x \leq 1 \), \( x - \frac{1}{2} \) is positive, so we have:
\[
\int_{\frac{1}{2}}^1 \left( x - \frac{1}{2} \right) \, dx = \int_{\frac{1}{2}}^1 \left( x - \frac{1}{2} \right) \, dx.
\]
Integrating:
\[
\int_{\frac{1}{2}}^1 \left( x - \frac{1}{2} \right) \, dx = \left[ \frac{x^2}{2} - \frac{x}{2} \right]_{\frac{1}{2}}^1 = \left( \frac{1^2}{2} - \frac{1}{2} \right) - \left( \frac{\left( \frac{1}{2} \right)^2}{2} - \frac{\frac{1}{2}}{2} \right).
\]
Simplifying:
\[
= \left( \frac{1}{2} - \frac{1}{2} \right) - \left( \frac{1}{8} - \frac{1}{4} \right) = 0 - \left( -\frac{1}{8} \right) = \frac{1}{8}.
\]
Step 3: Add the results.
Now, add the results of the two integrals:
\[
I = \frac{1}{8} + \frac{1}{8} = \frac{1}{4}.
\]
Thus, the value of the integral is \( \frac{1}{4} \), and the correct answer is (b).