C++ - how to apply separate filter

so could you share with me how to put into a for loop? thanks.