Cavities and fractures significantly affect the flow paths in carbonate reservoirs and should be accurately accounted for in numerical models. Herein, we consider the problem of computing the effective permeability of rock samples based on high-resolution 3D CT scans containing millions of voxels. We use the Stokes-Brinkman equations in the entire domain, covering regions of free flow governed by the Stokes equations, porous Darcy flow, and transitions between them. The presence of different length scales and large (ten orders of magnitude) contrasts in permeability leads to highly ill-conditioned linear systems of equations, which are difficult to solve. To obtain a problem that is computationally tractable, we first analyze the relative importance of the Stokes and Darcy terms for a set of idealized 2D models. We find that, in terms of effective permeability, the Stokes-Brinkman equations are only applicable for a special parameter set where the effective free-flow permeability is less than four orders of magnitude different from the matrix permeability. All other cases can be accurately modeled with either the Stokes or the Darcy end-member flows, depending on if there do or do not exist percolating free-flow regions. The insights obtained are used to perform a direct computation of the effective permeability of a rock sample model with more than 8 million cells.