Memristor is a newfound circuit element that has the ability of both memory and computing, which brings new opportunity for the development of computer architecture. Image processing is a type of memory-access-intensive application, where large part of time is spent in reading and writing image data. Therefore, we consider using memristors' property of having the ability of both memory and computing to realize some basic image operations, thus avoiding or reducing memory access of image data. In this paper, we propose algorithms achieving image segmentation with threshold based on memristors. First of all, we consider 8-bit gray image segmentation with specific thresholds, including 64, 128 and 192, where the comparison step could by simple. Then, we focus on image segmentation with general threshold, where the key step is to implement comparison of two 8-bit data. We design the comparison algorithm for 8-bit data based on memristors and use it in image segmentation with general threshold. The experimental results and theoretical analysis indicate that, our design is right in function, and could reduce memory access effectively.