v9.1.1
Menu

Brightness Adjustment

easyFREEPoint OperatorsImage ProcessingCV: Image Processing

Implement a point operator to adjust the brightness of an image by modifying the intensity of each pixel. This task involves understanding how to apply a simple transformation to every pixel in an image.

The concept of brightness adjustment is fundamental in image processing, as it allows for the enhancement or correction of images based on their lighting conditions. The process involves adding a constant value to each pixel's intensity, which can be represented mathematically.

  1. Start with the input image Iin(x,y)I_{in}(x,y), where (x,y)(x,y) represents the coordinates of a pixel.
  2. Add a constant β\beta to the intensity of each pixel. The resulting output image Iout(x,y)I_{out}(x,y) is calculated by applying this transformation and ensuring the values stay within the valid range.
Iout(x,y)=clamp(Iin(x,y)+β,0,255)I_{out}(x,y) = \text{clamp}(I_{in}(x,y) + \beta, 0, 255)

This technique is widely used in photography editing software.

Example

Input
adjust_brightness([[100, 200]], 50)
Output
[[150, 250]]
Reasoning
  • image is a grid of grayscale intensities, here one row holding two pixels, 100100 and 200200. Each value lies in [0,255][0, 255], where 00 is black and 255255 is white. beta =50= 50 is the offset applied to every pixel.
  • Apply Iout(x,y)=clamp(Iin(x,y)+β,0,255)I_{out}(x,y) = \text{clamp}(I_{in}(x,y) + \beta, 0, 255): 100+50=150100 + 50 = 150 and 200+50=250200 + 50 = 250.
  • Both sums already lie inside [0,255][0, 255], so clamping leaves them unchanged. The result is [[150, 250]], the same 1×21 \times 2 shape as the input, still whole-number intensities.
  • Clamping only matters near the ends of the range. With β=10\beta = 10, a pixel of 250250 would give 260260, which saturates to 255255. With β=−20\beta = -20, a pixel of 1010 would give −10-10, which is floored to 00.
  • Notice that every unclamped pixel shifts by the same amount, so the gap between them is preserved: 250−150=200−100=100250 - 150 = 200 - 100 = 100. Brightness changes, contrast does not.

Constraints

  • beta can be positive (brighten) or negative (darken)
  • Clamp output to [0, 255]

Learn this in

More from CV: Image Processing

solution.py

Test results

Sign in to run your code against the test cases.