0
0
Computer Visionml~10 mins

Color transforms (brightness, contrast, hue) in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to increase the brightness of an image by adding a value to all pixels.

Computer Vision
bright_img = img + [1]
Drag options to blanks, or click blank then click option'
A50
B0.5
C-50
D255
Attempts:
3 left
💡 Hint
Common Mistakes
Using a value less than 1 like 0.5 which is too small for brightness increase
Using negative values which decrease brightness
2fill in blank
medium

Complete the code to adjust contrast by multiplying pixel values by a factor.

Computer Vision
contrast_img = img * [1]
Drag options to blanks, or click blank then click option'
A0
B0.5
C-1
D1.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or negative values which remove or invert the image
Using values less than 1 which reduce contrast
3fill in blank
hard

Fix the error in the code to correctly convert an RGB image to HSV and adjust the hue.

Computer Vision
hsv_img = cv2.cvtColor(img, [1])
hsv_img[:, :, 0] = (hsv_img[:, :, 0] + 10) % 180
Drag options to blanks, or click blank then click option'
Acv2.COLOR_BGR2HSV
Bcv2.COLOR_HSV2BGR
Ccv2.COLOR_RGB2HSV
Dcv2.COLOR_BGR2GRAY
Attempts:
3 left
💡 Hint
Common Mistakes
Using BGR to HSV conversion when image is RGB
Using HSV to BGR conversion which is backward
4fill in blank
hard

Fill both blanks to create a function that adjusts brightness and contrast of an image.

Computer Vision
def adjust_brightness_contrast(img, brightness, contrast):
    return img * [1] + [2]
Drag options to blanks, or click blank then click option'
Acontrast
Bbrightness
Cimg
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping brightness and contrast
Adding brightness before multiplying contrast
5fill in blank
hard

Fill all three blanks to adjust hue, saturation, and value in an HSV image.

Computer Vision
hsv_img[:, :, 0] = (hsv_img[:, :, 0] + [1]) % 180
hsv_img[:, :, 1] = hsv_img[:, :, 1] * [2]
hsv_img[:, :, 2] = hsv_img[:, :, 2] * [3]
Drag options to blanks, or click blank then click option'
A10
B1.2
C0.8
D180
Attempts:
3 left
💡 Hint
Common Mistakes
Using 180 instead of 10 for hue shift
Multiplying saturation or value by values greater than 1 incorrectly