In these years, owing to aging population and Western-style food, kidney disease patients are increasing. It is difficult for people to recover all of kidney disease. Early detection of a kidney disease is therefore needed. But diagnosis based on CT images has faults that are time-consuming and a great labor is required since the quantity of CT images is huge. In this paper, we propose a method that automatically extracts a kidney region as a preprocessing of kidney failure detection. The kidney region is detected based on contour information that is extracted from the CT image using a dynamic gray scale value refinement method by Q-learning. It is demonstrated that the proposed method can detect stably the kidney from CT images of any patients.