MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / convert_to_negative

Function convert_to_negative

digital_image_processing/convert_to_negative.py:8–17  ·  view source on GitHub ↗
(img)

Source from the content-addressed store, hash-verified

6
7
8def convert_to_negative(img):
9 # getting number of pixels in the image
10 pixel_h, pixel_v = img.shape[0], img.shape[1]
11
12 # converting each pixel's color to its negative
13 for i in range(pixel_h):
14 for j in range(pixel_v):
15 img[i][j] = [255, 255, 255] - img[i][j]
16
17 return img
18
19
20if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected