D. The image hue is shifted by 30 degrees on the color wheel
Solution
Step 1: Understand HSV color space and hue channel
HSV separates color into Hue, Saturation, and Value. Hue channel controls color angle on the wheel.
Step 2: Analyze code effect on hue channel
The code adds 30 to the hue channel and wraps around with modulo 180, shifting colors on the wheel.
Final Answer:
The image hue is shifted by 30 degrees on the color wheel -> Option D
Quick Check:
Hue shift = color rotation [OK]
Hint: Hue changes rotate colors in HSV space [OK]
Common Mistakes:
Confusing hue shift with brightness or contrast
Ignoring modulo wrap-around for hue
Assuming color space conversion changes brightness
4. The following code attempts to increase image contrast but does not work as expected. What is the main error?
def increase_contrast(img):
mean = img.mean()
return (img - mean) * 1.2 + mean
result = increase_contrast(image)
medium
A. The image should be converted to grayscale first
B. The multiplication factor should be less than 1
C. The mean should be computed per channel, not overall
D. The code should add 1.2 instead of multiplying
Solution
Step 1: Understand contrast adjustment per channel
Contrast should be adjusted per color channel to preserve color balance.
Step 2: Identify error in mean calculation
The code calculates mean over entire image, mixing channels, causing wrong contrast scaling.
Final Answer:
The mean should be computed per channel, not overall -> Option C
Quick Check:
Contrast per channel = correct scaling [OK]
Hint: Calculate mean per channel for contrast adjustment [OK]
Common Mistakes:
Using single mean for all channels
Using factor less than 1 reduces contrast
Adding constant changes brightness, not contrast
5. You want to apply a color transform pipeline to an image that first increases brightness by 20%, then shifts hue by 45 degrees, and finally increases contrast by 30%. Which order of operations is best to preserve natural colors?
hard
A. Increase contrast -> Shift hue -> Increase brightness
B. Increase brightness -> Increase contrast -> Shift hue
C. Shift hue -> Increase brightness -> Increase contrast
D. Shift hue -> Increase contrast -> Increase brightness
Solution
Step 1: Consider effect of brightness before contrast
Increasing brightness first ensures pixel values are lifted before stretching differences with contrast.
Step 2: Apply hue shift last to avoid color distortion
Hue shift should be last to rotate colors after brightness and contrast adjustments.
Step 3: Confirm order preserves natural colors
Brightness -> Contrast -> Hue maintains natural look by adjusting lightness and contrast before color rotation.