In a program generation apparatus, a processing unit selects a first program from among a plurality of image processing programs each generated by combining a plurality of partial programs; generates a second program by changing a part of the partial programs included in the first program; performs image processing on an input image, using the second program; determines whether to pass the second program to the next generation, based on a comparison between one or more intermediate output images that are output halfway through the image processing and a first target image; and replaces one of the image processing programs with the second program when the second program is determined to be passed to the next generation.
Please help me write a proper abstract based on the patent claims. CLAIM: 1. A program generation apparatus that generates a program by using genetic programming, the program generation apparatus comprising: a memory configured to store learning data including an input image and a first target image, the first target image indicating an image that is output halfway through a process of converting the input image into a second target image; and a processor configured to perform a procedure including: selecting a first program from among a plurality of image processing programs each generated by combining a plurality of partial programs, generating a second program by changing a part of the partial programs included in the first program, performing image processing on the input image using the second program, determining whether to pass the second program to a next generation, based on a comparison between one or more intermediate output images and the first target image, the one or more intermediate output images being output halfway through the image processing, and replacing one of the plurality of image processing programs with the second program when the second program is determined to be passed to the next generation. 2. The program generation apparatus according to claim 1, wherein: the performing includes executing non-final partial programs from among the partial programs included in the second program, the non-final partial programs being incorporated in positions other than a final stage, and outputting the intermediate output images for the respective non-final partial programs; and the determining includes calculating evaluation values for the respective non-final partial programs, based on a comparison between each of the intermediate output images that are output for the respective non-final partial programs and the first target image, and determining whether to pass the second program to the next generation, based on a maximum value among the evaluation values. 3. The program generation apparatus according to claim 1, wherein: the procedure further includes performing processes on the input image using the respective image processing programs, and calculating a weight coefficient based on a comparison between each of images that are output halfway through the respective processes and the first target image; and the determining includes calculating a first evaluation value based on the comparison between the one or more intermediate output images and the first target image, calculating a second evaluation value based on a comparison between a final output image and the second target image, the final output image being output as a result of the image processing, and determining whether to pass the second program to the next generation, based on a third evaluation value obtained by synthesizing the first evaluation value and the second evaluation value at a ratio corresponding to the weight coefficient. 4. The program generation apparatus according to claim 1, wherein: the procedure further includes calculating a weight coefficient, based on a number of times of generation change of a population that includes the plurality of image processing programs as individuals of a current generation; and the determining includes calculating a first evaluation value based on the comparison between the one or more intermediate output images and the first target image, calculating a second evaluation value based on a comparison between a final output image and the second target image, the final output image being output as a result of the image processing, and determining whether to pass the second program to the next generation, based on a third evaluation value obtained by synthesizing the first evaluation value and the second evaluation value at a ratio corresponding to the weight coefficient. 5. The program generation apparatus according to claim 1, wherein: the first target image is an image obtained by distinguishing between a first image region on which specific processing is performed and a second image region other than the first image region in the input image; and the second target image is an image obtained by performing the specific processing on the first image region of the input image. 6. A program generation method for generating a program by using genetic programming, the program generation method comprising: selecting, by a processor, a first program from among a plurality of image processing programs each generated by combining a plurality of partial programs; generating, by the processor, a second program by changing a part of the partial programs included in the first program; performing, by the processor, image processing on an input image using the second program; determining, by the processor, whether to pass the second program to a next generation, based on a comparison between one or more intermediate output images and a first target image, the one or more intermediate output images being output halfway through the image processing, the first target image indicating an image that is output halfway through a process of converting the input image into a second target image; and replacing, by the processor, one of the plurality of image processing programs with the second program when the second program is determined to be passed to the next generation. 7. A non-transitory computer-readable storage medium storing a computer program for generating a program by using genetic programming, the computer program causing a computer to perform a procedure comprising: selecting a first program from among a plurality of image processing programs each generated by combining a plurality of partial programs; generating a second program by changing a part of the partial programs included in the first program; performing image processing on an input image using the second program; determining whether to pass the second program to a next generation, based on a comparison between one or more intermediate output images and a first target image, the one or more intermediate output images being output halfway through the image processing, the first target image indicating an image that is output halfway through a process of converting the input image into a second target image; and replacing one of the plurality of image processing programs with the second program when the second program is determined to be passed to the next generation.