The following is a part of a function that patches triangles with the corresponding colours using a for-loop
for i = 1:numel(tri)/3 color(i, :) = img(center(i,1), center(i,2),:); %gets current color from img
patch(points(tri(i,:), 2), points(tri(i,:), 1), color(i,:)/256, 'EdgeColor','none'); %patches color on polygon
end %size(tri) = 44721x3
%size(color) = 44271x3
%size(points) = 22429x2
%size(points(tri(i,:),1) = 3x1
%size(points(tri(i,:),2) = 3x1
%size(color(i,:)/256) = 1x3
The only problem is that patching this large number of polygons takes a long time (+/- 19s). Tried using `fill` instead of `patch` to see if that was faster, but sadly that was 13s slower.
Is there a way to speed up the patching process? For example by patching all the polygons in 1 sweep without looping?
Best Answer