0

Is that possible to reduce the brightness area and i want the result like below enter image description here

This is the part that i want the brightness area to become with
enter image description here

Lim Weihan
  • 55
  • 1
  • 7
  • Please explain in more detail which part of the input image you want darkened. Also is the first image your input or output? Please post your input image. Change the whole image's brightness, then copy the part you want into the original image. – fmw42 Mar 04 '20 at 18:04
  • Please show your **actual** input image without borders and without window title decorations. Why has the output image suddenly changed size? Do you mean you want to crop out part of the image? – Mark Setchell Mar 04 '20 at 18:23

2 Answers2

0

You can change the brightness of the whole picture but I'm not sure how to make a part of it. I think this link helps you.

  • This is not an answer but a comment please visit and check [how to answer a question](https://stackoverflow.com/help/how-to-answer). – Yunus Temurlenk Mar 04 '20 at 17:25
0
  1. Determine the brightness region in your image. My solution is that I counted each pixel(channel value > 100) in each column and decided a reference number. If the number is bigger than the reference(I chose 55), I considered columns is close to bright(255).
  2. After first step, the brightness area is clear so just crop that area.
  3. Decrease the brightness of the area. Helpful link is here to decrease brightness.
  4. After decreasing the brightness just replace it with the original part in the source image.

Here is the solution for first step and result.

import cv2

img=cv2.imread("/ur/source/image/bright.png")
height, width, channels = img.shape

thresh = [100,100,100]
white = [255,255,255]
white_counter = 0

for x in range(0,width):
    for y in range(0,height):
        channels_xy = img[y,x]
        if all(channels_xy >= thresh):    
            white_counter += 1

    if(white_counter>55):
        for k in range(0,height): 
            img[k,x] = white

    white_counter = 0

cv2.imshow('Result',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Result:

enter image description here

Yunus Temurlenk
  • 4,085
  • 4
  • 18
  • 39