In the below snippet code basically trying to filter an image using PARFOR, been getting an error saying "The varible hatx in a parfor cannot be classified". Needed help me in paralleling the for loop as the filtering process time increases with the size of the image. Variables being m,n and d are the size dimension of the input image.
parfor i = 1:m for j = 1:n % Extract local region.
iMin = max(i-c,1); iMax = min(i+c,m); jMin = max(j-c,1); jMax = min(j+c,n); I = f(iMin:iMax,jMin:jMax,:); H=gpuArray(I(:,:,1)-f(i,j,1).^2); for k=2:d H=H+(I(:,:,k)-f(i,j,k)).^2; end H=gpuArray(exp(-H./((2*sigmar^2)))); % Calculate bilateral filter response.
F = gpuArray(H.*G((iMin:iMax)-i+c+1,(jMin:jMax)-j+c+1)); norm_F = sum(F(:)); for k=1:d hatx(i,j,k) = (sum(sum(F.*I(:,:,k)))/norm_F); end endend
But I get the error "The variable hatx in a parfor cannot be classified". can someone help with the solution, I tried the MATLAB answered in the link https://in.mathworks.com/matlabcentral/answers/52005-how-to-transform-these-three-nested-for-loops-into-a-parfor-loop Still not able to execute the code using PARFOR, Can somebody please help fix this. Thanks,
S.Suhas
Best Answer