Image segmentation is the process of separating pixels of an image into multiple classes, enabling the analysis of objects in the image. Multilevel thresholding (MTH) is a method used to perform this task, and the problem is to obtain an optimal threshold that properly segments each image. Methods such as the Kapur entropy or the Otsu method, which can be used as objective functions to determine the optimal threshold, are efficient in determining the best threshold for bi-level thresholding; however, they are not effective for MTH due to their high computational cost. This paper integrates an efficient method for MTH image segmentation called the heap-based optimizer (HBO) with opposition-based learning termed improved heap-based optimizer (IHBO) to solve the problem of high computational cost for MTH and overcome the weaknesses of the original HBO. The IHBO was proposed to improve the convergence rate and local search efficiency of search agents of the basic HBO, the IHBO is applied to solve the problem of MTH using the Otsu and Kapur methods as objective functions. The performance of the IHBO-based method was evaluated on the CEC’2020 test suite and compared against seven well-known metaheuristic algorithms including the basic HBO, salp swarm algorithm, moth flame optimization, gray wolf optimization, sine cosine algorithm, harmony search optimization, and electromagnetism optimization. The experimental results revealed that the proposed IHBO algorithm outperformed the counterparts in terms of the fitness values as well as other performance indicators, such as the structural similarity index (SSIM), feature similarity index (FSIM), peak signal-to-noise ratio. Therefore, the IHBO algorithm was found to be superior to other segmentation methods for MTH image segmentation.