android-gpuimage
android-gpuimage copied to clipboard
Apply Multiple filter at same time
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.
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.
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.
// 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
Please share the solution if anyone found it. I am facing the same issue and wasting my time on it.
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.
// 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.
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.