You can try:

gray = cv2.convertScaleAbs(sobely, alpha=255/sobely.max())
plt.imshow(gray, cmap='gray')

Answer from sim0ne on Stack Overflow
🌐
Shimat
shimat.github.io › opencvsharp_docs › html › 7633dbe6-e0b8-23bf-6966-dc9b4720e3d1.htm
Cv2.ConvertScaleAbs Method
public static void ConvertScaleAbs( InputArray src, OutputArray dst, double alpha = 1, double beta = 0 )
🌐
DEV Community
dev.to › jarvissan22 › cv2-what-is-an-image-lets-adjust-the-brightness-and-contrast-of-an-image-35po
CV2: What is an Image?, Lets adjust the Brightness and Contrast of an image - DEV Community
November 29, 2024 - Example Usage: new_image = cv2.convertScaleAbs(image, alpha=contrast, beta=brightness) This allows us to easily modify brightness and contrast without manually clipping pixel values.
🌐
ProgramCreek
programcreek.com › python › example › 89330 › cv2.convertScaleAbs
Python Examples of cv2.convertScaleAbs
Got {}'.format(type(img))) table = np.array([ i*brightness_factor for i in range (0,256)]).clip(0,255).astype('uint8') # same thing but a bit slower # cv2.convertScaleAbs(img, alpha=brightness_factor, beta=0) if img.shape[2]==1: return cv2.LUT(img, table)[:,:,np.newaxis] else: return cv2.LUT(img, table)
🌐
Readthedocs
opencv-laboratory.readthedocs.io › en › latest › nodes › core › convertScaleAbs.html
convertScaleAbs — OpenCV Laboratory 1.0 alpha documentation
convertScaleAbs · Edit on GitHub · Scales, calculates absolute values, and converts the result to 8-bit. alpha_in – Optional scale factor. beta_in – Optional delta added to the scaled values. image_in – Input image.
🌐
YouTube
youtube.com › computer vision lab
OPENCV & C++ TUTORIALS - 99 | convertScaleAbs() | Absolute conversion of pixels - YouTube
The convertScaleAbs() function in OpenCV is used to perform scaling and absolute value conversion on the elements of an input array. It is primarily used for...
Published: June 19, 2023
Views: 476
🌐
OpenCV
docs.opencv.org › 2.4.13.7 › modules › core › doc › operations_on_arrays.html
Operations on Arrays — OpenCV 2.4.13.7 documentation
December 31, 2019 - Matrix Expressions, absdiff(), convertScaleAbs() Calculates the per-element absolute difference between two arrays or between an array and a scalar. C++: void absdiff(InputArray src1, InputArray src2, OutputArray dst)¶ · Python: cv2.absdiff(src1, src2[, dst]) → dst¶ ·
🌐
GitHub
github.com › opencv › opencv › issues › 11751
What's the operation dose "cv2.convertScaleAbs" actually do? · Issue #11751 · opencv/opencv
June 13, 2018 - I want to convert a float64 array to uint8 array. The result given by cv2.convertScaleAbs looked correct iin cv2.imshow. But when I followed doc to implement it by tensorflow and numpy, it got different result. Part of source array: scal...
Find elsewhere
🌐
OpenCV Courses
opencv.courses › blog › image-enhancement-with-opencv
Image Enhancement with OpenCV | Open CV Courses
import cv2 # Load image image = cv2.imread('input_image.jpg') # Adjust brightness and contrast alpha = 1.5 # Contrast control (1.0 means no change) beta = 30 # Brightness control (0-100, with 0 being black) adjusted_image = cv2.convertScaleAbs(image, alpha=alpha, beta=beta) # Display the enhanced image cv2.imshow('Enhanced Image', adjusted_image) cv2.waitKey(0) cv2.destroyAllWindows()
🌐
Openlvvision
openlvvision.org › home › opencv › core functionality › arithmetic operations › convertscaleabs
ConvertScaleAbs | OpenLvVision
On each element of the input array, the function convertScaleAbs performs three operations sequentially: scaling, taking an absolute value, and conversion to an unsigned 8-bit type:
🌐
OpenCV
docs.opencv.org › 4.13.0 › d3 › dc1 › tutorial_basic_linear_transform.html
OpenCV: Changing the contrast and brightness of an image!
new_image = cv.convertScaleAbs(image, alpha=alpha, beta=beta) cv::convertScaleAbs · void convertScaleAbs(InputArray src, OutputArray dst, double alpha=1, double beta=0) Scales, calculates absolute values, and converts the result to 8-bit. where cv::Mat::convertTo would effectively perform ...
🌐
Huihoo
docs.huihoo.com › opencv › 2.4-documentation › modules › core › doc › operations_on_arrays.html
Operations on Arrays — OpenCV 2.4.13.2 documentation
Matrix Expressions, absdiff(), convertScaleAbs() Calculates the per-element absolute difference between two arrays or between an array and a scalar. C++: void absdiff(InputArray src1, InputArray src2, OutputArray dst)¶ · Python: cv2.absdiff(src1, src2[, dst]) → dst¶ ·
🌐
Medium
arsanatl.medium.com › mastering-basic-image-operations-in-opencv-e2e8821b50bd
Mastering Basic Image Operations in OpenCV | by Sanat Ladkat | Medium
August 24, 2024 - Adjusting Brightness and Contrast: cv2.convertScaleAbs(image, alpha=alpha, beta=beta): Applies scaling and shifting to each pixel.
🌐
Medium
medium.com › @lyxmaple › python筆記-opencv-3-e02fa6761f0
Python筆記-OpenCV (3). 延續上一篇 | by Fuu | Medium
July 6, 2023 - import cv2 img = cv2.imread('圖片路徑') #alpha用於調整對比度,beta用於調整亮度 alpha = 1.2 # 對比度控制因子 (1.0-3.0) beta = 15 # 亮度控制因子 (0-100) # 使用cv2.convertScaleAbs()函數調整影像的對比度和亮度。 # 該函數會確保所有的像素值都在 0-255 的範圍內 img1 = cv2.convertScaleAbs(img, alpha=alpha, beta=beta) # 顯示原始影像和調整後的影像 cv2.imshow('img', img) # 顯示原始影像 cv2.imshow('img1', img1) # 顯示調整後的影像 cv2.waitKey(0)
🌐
MakeUseOf
makeuseof.com › home › programming › master image enhancement techniques with opencv
Master Image Enhancement Techniques With OpenCV
June 13, 2023 - The cv2.convertScaleAbs function adjusts the brightness of the image. The alpha parameter controls the contrast, while the beta parameter controls the brightness.
🌐
Amroamroamro
amroamroamro.github.io › mexopencv › matlab › cv.convertScaleAbs.html
cv.convertScaleAbs - mexopencv
cv.convertScaleAbs - Scales, calculates absolute values, and converts the result to 8-bit
🌐
GeeksforGeeks
geeksforgeeks.org › image-enhancement-techniques-using-opencv-python
Image Enhancement Techniques using OpenCV - Python - GeeksforGeeks
April 28, 2025 - Another method for adjusting the brightness and contrast of an image is to use the cv2.convertScaleAbs() function, which allows you to adjust the brightness and contrast using a combination of scaling and shifting the pixel values.