Reputation: 21
Can i invert each color and generate a inverted RGB image by matlab code? and how? i want to invert each color then calculate the sum which is the new value for the pixel somehow like this ((255-R)+(255-B)+(255-G)) thnx
Upvotes: 1
Views: 10182
Reputation: 32883
myimage = sum(255 - myimage, 3);
Explanation:
255 - myimage
does the pixel-wise color inversion, e.g. for each pixel, the R component becomes (255-R) and so on…
sum(…, 3)
does the pixel-wise sum of each of the 3 layers of the image (Red, Green and Blue)
You end up with a single layer image where each pixel stores the corresponding sum that you are looking for.
Upvotes: 4