The main goal of this paper is to attain accurate and automatic detection of brain tumors in gray magnetic resonance images using reducing the local dimensions. We propose a novel model called Improved Mixtures of Factor Analyzers based on Dynamic Co-Clustering (IMFADCC) for the detection and localization of brain tumors. After image preprocessing and enhancement, the optimal numbers of row clusters and column clusters corresponding to each row cluster, alongside other model parameters, are determined concurrently based on the size of the tumor by our model. Then, using the optimal values obtained, the image is co-clustered by simultaneously clustering rows and columns until the block containing the tumor is identified. The output image is divided into a certain number of blocks, one of which contains the tumor. For post-processing, the identified block is binarized using minimum error thresholding. The proposed model accurately detects and locates the block binarized within the original image while considering the remainder of the image as background. The effectiveness of the proposed method was assessed by evaluating its accuracy, Dice, intersection on union, geometric mean, receiver operating characteristic curve, specificity, and sensitivity criteria on the BraTS2018, BraTS2019, and BraTS2020 datasets. The results show that our method has significant performance and is highly accurate in detecting tumors of different sizes in complex and high-size images. Moreover, our method outperforms the existing diagnostic methods.