AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Im = cv2.imread(filename, cv2. So, here's what you actually asked for: #!/usr/bin/env python3 However, if you really want Python/OpenCV code, I note none of the existing answers do that - some use a different library, some are incomplete, some do superfluous blurring and some read video cameras for some unknown reason, and none handle more than one image or errors. In the evening I turn on the ceiling light. The room has windows to my right with curtains that let some light through or they might be open a bit during the day. Note that both these methods will work for many image types, from PNG, through GIF, JPEG and TIFF. I have always used my displays calibrated to 120 nits brightness, which can mean pretty low brightness settings on the monitor. The vips answer is on a scale of 0.255 for 8-bit images. You can just use ImageMagick at the command-line in your Terminal to get the mean brightness of an image as a percentage, where 100 means "fully white" and 0 means "fully black", like this: convert someImage.jpg -format "%" info:Īlternatively, you can use libvips which is less common, but very fast and very lightweight: vips avg someImage.png If you absolutely have to use Python, please just disregard this answer and select a different one. Then modify the input image everywhere with your current method. So setting scaleFactor 0.75 and offset 0 should do the trick. That amounts to multiplying the pixel values by 0.75. Now suppose you want to make the image darker, at 75 brightness like you say. Personally, I would not bother writing any Python, or loading up OpenCV for such a simple operation. If you only want to increase the brightness of the purple, then use cv2.inRange() for the purple color to create a mask. Setting scaleFactor 1 and offset 0 does the trick.
0 Comments
Read More
Leave a Reply. |