We consider a singularly-perturbed nonconvex energy functional which arises in the study of microstructures in shape memory alloys. The scaling law for the minimal energy predicts a transition from a parameter regime in which uniform structures are favored, to a regime in which the formation of fine patterns is expected. We focus on the transition regime and derive the reduced model in the sense of $Gamma$-convergence. The limit functional turns out to be similar to the Mumford-Shah functional with additional constraints on the jump set of admissible functions. One key ingredient in the proof is an approximation result for $SBV^p$ functions whose jump sets have a prescribed orientation.