android-gpuimage icon indicating copy to clipboard operation
android-gpuimage copied to clipboard

Apply Multiple filter at same time

Open akashdeepad opened this issue 7 years ago • 7 comments

I want to apply multiple filters on an image. For the very first time I can apply filters using GPUImageFilterGroup. Lets assume, I am adding CONTRAST and BRIGHTNESS to the filter group, then I want to update CONTRAST, then switch to BRIGHTNESS and apply BRIGHTNESS change to same image, to which I have already applied CONTRAST.

So, how can I increase or decrease the properties separately on same image. Currently, for me both properties are applied on the original image, not on filtering image.

Please assist.

akashdeepad avatar May 26 '17 13:05 akashdeepad

Hi @akashdeepad I am trying to solve this problem as well. What I am doing is using a HashMap to cache the progress value from the seekbar for each of the Filters. When users switch back to the Filter they have used, the app does a check and set the progress integer back to the seekbar.

Not sure if there is any of the better solutions, if there is any, please help to share. Thanks.

gengrui1983 avatar Jun 07 '17 06:06 gengrui1983

I think original image is always needed in this case. When user changes parameter of the filter, just apply the final filter on the original image.

houxiaomu avatar Jul 11 '17 05:07 houxiaomu

// group filter setting List<GPUImageFilter> chainFilters = new LinkedList<GPUImageFilter>(); .... chainFilters.add(new GPUImagePixelationFilter()); chainFilters.add(new GPUImageBrightnessFilter(0.3f)); chainFilters.add(new GPUImageContrastFilter()); return new GPUImageFilterGroup(chainFilters);

// using group filter and can select respectable filter if (mFilter.getClass().isInstance(new GPUImageFilterGroup())) { GPUImageFilterGroup mfilters = (GPUImageFilterGroup)mFilter; mergedFilters = mfilters.getMergedFilters(); }

// set adjuster filter mFilterAdjuster = new FilterAdjuster(mergedFilters.get(1)); // this filter is brightness

dyjung avatar Jan 12 '18 01:01 dyjung

Please share the solution if anyone found it. I am facing the same issue and wasting my time on it.

hardapps1692 avatar Jun 15 '20 18:06 hardapps1692

Hi @akashdeepad I am trying to solve this problem as well. What I am doing is using a HashMap to cache the progress value from the seekbar for each of the Filters. When users switch back to the Filter they have used, the app does a check and set the progress integer back to the seekbar.

Not sure if there is any of the better solutions, if there is any, please help to share. Thanks.

Please share the code so we can take some ideas.

hardapps1692 avatar Jun 15 '20 18:06 hardapps1692

// group filter setting List chainFilters = new LinkedList(); .... chainFilters.add(new GPUImagePixelationFilter()); chainFilters.add(new GPUImageBrightnessFilter(0.3f)); chainFilters.add(new GPUImageContrastFilter()); return new GPUImageFilterGroup(chainFilters);

// using group filter and can select respectable filter if (mFilter.getClass().isInstance(new GPUImageFilterGroup())) { GPUImageFilterGroup mfilters = (GPUImageFilterGroup)mFilter; mergedFilters = mfilters.getMergedFilters(); }

// set adjuster filter mFilterAdjuster = new FilterAdjuster(mergedFilters.get(1)); // this filter is brightness

What about adjuster? It always resets the values of the filter. Please update code if you found a solution.

hardapps1692 avatar Jun 15 '20 18:06 hardapps1692

Hi @akashdeepad I am trying to solve this problem as well. What I am doing is using a HashMap to cache the progress value from the seekbar for each of the Filters. When users switch back to the Filter they have used, the app does a check and set the progress integer back to the seekbar.

Not sure if there is any of the better solutions, if there is any, please help to share. Thanks.

please share the code. So more rework.

hardapps1692 avatar Jun 20 '20 18:06 hardapps1692