package org.test.filter;

import marvin.image.MarvinImage;
import org.test.filter.core.BaseFilter;
import org.test.filter.core.ColorFilter;
import org.test.filter.core.FilterContext;

/**
 * Created by BORIS on 19.08.2017.
 */
public class GreenFilter extends BaseFilter implements ColorFilter<MarvinImage, MarvinImage> {

    public GreenFilter(FilterContext filterContext) {
        super(filterContext);
    }

    @Override
    public MarvinImage filter(MarvinImage image) {
        super.filter(image);
        int r, g, b;
        for (int y = 0; y < image.getHeight(); y++) {
            for (int x = 0; x < image.getWidth(); x++) {
                r = image.getIntComponent0(x, y);
                g = image.getIntComponent1(x, y);
                b = image.getIntComponent2(x, y);
                if (g > r * 1.5 && g > b * 1.5) {
                    image.setIntColor(x, y, 255, 255, 255);
                }
            }
        }

        return image;
    }

}
