Knowledge- and sample-based learning approaches play a pivotal role in image processing. However, the acquisition and integration of expert knowledge (for the former) and providing a sufficiently large number of training samples (for the latter) are generally hard to perform and time-consuming tasks. Hence, learning image processing tasks from a few gold/ground-truth samples, prepared by the user, is highly desirable. This paper demonstrates how the combination of an optimizer (e.g., genetic algorithm) and image processing tools (e.g., parameterized morphology operations) can be used to generate image processing procedures for image filtering and object extraction. For this purpose, the approach receives the original and the user-prepared image (filtered image or image with extracted target object) as a gold sample which reflects the user's expectations. After carrying out the training or optimization phase, the optimal procedure is generated and ready to be applied to new images. The feasibility of our approach is investigated for two individual image processing categories, namely filtering and object extraction, by well-prepared synthetic images. The proposed architecture and the employed methodologies are explained in detail. Experimental results are provided as well.The subject matter in this work is covered by a US provisional patent application.