Question: Invert The Invert function converts the supplied image ( RGB or greyscale ) to its opposite colours ( complementary hues ) and returns the inverted

Invert
The Invert function converts the supplied image (RGB or greyscale) to its opposite colours (complementary hues) and returns the inverted image.
Input:
An m-by-n-by-k uint 8 array representing an RGB or greyscale colour image.
Output:
An m-by-n-by-k uint 8 array representing the inverted image.
Suppose we have an image stored in the uint 8 array named picture. This may be either m-byn-by-3 or m-by-n-by-1, depending on if it is an RGB or greyscale image.
To invert an image, the Invert function will need to calculate the opposite colour value for each pixel in the image. We can do this by subtracting the colour values in each pixel from 255(the maximum uint 8 value).
For example, at pixel position (1,1), we might have (r,g,b)=(200,55,80). Applying our inversion formula would result in the colour values:
invertedr=255-200=55
invertedg=255-55=200
invertedb=255-80=175
So pixel (1,1) has the new colour values (55,200,175) in the output inverted image.
Figure 2: Pixel with value (r,g,b)=(200,55,80) inverted with the Invert function.
Careful! Output Data Array Type
The output returned by Invert can either be a 2 D or 3 D array depending on what the input was. Make sure your function can handle a m-by-n-by -3 or m-by-n-by-1 array appropriately.
Stop: Forbidden Functions
Need Matlab code
Invert The Invert function converts the supplied

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!