I can make a non-linear mask based on the two arrays containing lower and higher boundary of the mask. All values in between need to be set to 1. The way I do this now seems to take quite a lot of time and it is becoming a bottleneck. I was wondering if there is a way to do it more time efficient.
First, I was thinking to solve it using parfors to increase the speed. But since this is one of the inner loops in my code these seem highly inefficient since it's more feasible using parfor on the outer loop considering schedule overhead. So parallel techniques are not an option.
See here the creation of the mask:
mask = zeros(size(im));
n = length(bufLow);
for i=1:1:n
mask(bufLow(i):bufHigh(i),i) = 1;
end
im is an matrix of a certain size and bufLow and bufHigh are arrays in size equal to the horizontal size of im describing the higher and lower boundaries for each column of im. In between these values everything needs to be set to 1.
So the goal is to have something that reduces the execution time of this loop as much as possible. I was wondering if there is somebody with some the knowledge to enlight me.
Bests,
Matthijs