Use a standard paint program like paint shop pro to edit your icons, save them in a MATLAB compatible format (bmp, png, jpeg, etc..)
Use White [RGB(255,255,255)] for areas you want white.
Use Black [RGB(0,0,0)] for areas you want black.
All other colors will be made transparent.
i = imread('mycursor.bmp');
CData = ConvertToCursor(i);
Richard Medlock (2020). Convert to Cursor (https://www.mathworks.com/matlabcentral/fileexchange/3328-convert-to-cursor), MATLAB Central File Exchange. Retrieved .
Alternatively you can avoid the double loop and reduce the code to the following line:
c2c = nan(size(i,1), size(i,2)); c2c(sum(i, 3)==765) = 2; c2c(sum(i, 3)==0) = 1;
it is a tooooooooooo greate