Problem: I'm a student and struggling for building a ideal low-pass filter for images. Considering that generating the mask for the ideal low-pass filter is a element-wise job, I decided to use GPU arrayfun to accelerate my computation and everything worked well in the MATLAB console, until I transformed my code to App Designer.
Here's the code to generate the mask:
function c = func3(app, x, y)
dx = x - app.center(1);
dy = y - app.center(2);
d = (dx^2 + dy^2)^(1/2);
if d > app.radius / 2
c = 0;
c = 1;
And the following is my code of the filter
app.shape = gpuArray(size(app.PollutedImage));
app.center = floor(app.shape / 2);
app.radius = min(app.center(1), app.center(2));
[X, Y] = meshgrid(1:app.shape(2), 1:app.shape(1));
spectrum = fftshift(fft2(app.PollutedImage));
if app.CurrentFilter == app.IdealLowPassFilter
mask = gpuArray(arrayfun(@(x, y) func3(app, x, y), X, Y));
filtered_spectrum = spectrum .* mask;
app.EnhancedImage = uint8(real(ifft2(fftshift(filtered_spectrum))));
Then I got the following error report:
Function passed as first input argument contains unsupported 'MCOS' language feature 'CLASSDEF'
Now I have to transform the mask generating job to a cpu version which is too slow but at least, doing its job(need to finish my homework) so is there any solution to this problem or using GPU arrayfun in App Designer is impossible, I wonder.
Thank you for your help!