Speeding up a color transformation loop

Another thing: as I understand here XYZlayers[j] is an array. Here you are creating a new array on the right side of the equation and replacing the array on that position with this new array. You probably want to update the current array, with XYXlayers[j] .= ... (note the dot in .=). Alternatively, you can use, for simplicity:

     @. XYZlayers[j] = XYZlayers[j] + (images[i] * IllumiCMF[j,i])	

See: Common allocation mistakes

edit: Indeed, the same @nsajko posted above.

1 Like