You can try:

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

Answer from sim0ne on Stack Overflow
🌐
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.
🌐
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)
🌐
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 )
🌐
Java2s
java2s.com › example › java-api › org › opencv › core › core › convertscaleabs-2-0.html
Example usage for org.opencv.core Core convertScaleAbs
void doSobel(String input, String output) { // load the image and read it into a matrix File f2 = new File(input); Mat image = Highgui.imread(this.input); // blur the image Imgproc.GaussianBlur(image, image, new Size(3, 3), 0, 0, Imgproc.BORDER_DEFAULT); // convert the image to gray Mat gray = new Mat(); Imgproc.cvtColor(image, gray, Imgproc.COLOR_BGR2GRAY); // parameters for our conversion int scale = 1; int delta = 0; int ddepth = CvType.CV_16S; // figure out the X gradient, get its absolute value Mat gx = new Mat(); Imgproc.Sobel(gray, gx, ddepth, 1, 0, 3, scale, delta, Imgproc.BORDER_DEFAULT); Mat abs_gx = new Mat(); Core.convertScaleAbs(gx, abs_gx); // do the same for Y Mat gy = new Mat(); Imgproc.Sobel(gray, gy, ddepth, 0, 1, 3, scale, delta, Imgproc.BORDER_DEFAULT); Mat abs_gy = new Mat(); Core.convertScaleAbs(gy, abs_gy);// w w w .
🌐
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 - image = cv2.imread('./test.png') cv2.namedWindow('Adjustments') contrast=0.8 brightness=89 image=cv2.convertScaleAbs(image, alpha=contrast, beta=brightness) cv2.imshow('Adjustments', image) cv2.waitKey(0) cv2.destroyAllWindows()
🌐
ProgramCreek
programcreek.com › python › example › 89330 › cv.convertScaleAbs
Python Examples of cv.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)
🌐
GeeksforGeeks
geeksforgeeks.org › image-enhancement-techniques-using-opencv-python
Image Enhancement Techniques using OpenCV - Python - GeeksforGeeks
April 28, 2025 - #Import the necessary libraries ... plt.imshow(image2) plt.show() ... In this example, the brightness and contrast are adjusted using a combination of scaling and shifting the pixel values....
🌐
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) # but we wanted to show you how to access the pixels :) for y in range(image.shape[0]): for x in range(image.shape[1]): for c in range(image.shape[2]): new_image[y,x,c] = np.clip(alpha*image[y,x,c] + beta, 0, 255) cv.imshow('Original ...
Find elsewhere
🌐
Amroamroamro
amroamroamro.github.io › mexopencv › matlab › cv.convertScaleAbs.html
cv.convertScaleAbs - mexopencv
On each element of the input array, the function cv.convertScaleAbs performs three operations sequentially: scaling, taking an absolute value, conversion to an unsigned 8-bit type:
🌐
OpenCV
docs.opencv.org › 3.4.20 › d2 › de8 › group__core__array.html
OpenCV: Operations on arrays
convertScaleAbs, Mat::convertTo · #include <opencv2/core.hpp> Calculates the magnitude of 2D vectors. The function cv::magnitude calculates the magnitude of 2D vectors formed from the corresponding elements of x and y arrays: \[\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\] Parameters · See also · cartToPolar, polarToCart, phase, sqrt · Examples: samples/cpp/polar_transforms.cpp.
🌐
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
🌐
Pub.dev
pub.dev › documentation › opencv_dart › latest › cv › convertScaleAbs.html
convertScaleAbs function - cv library - Dart API
dst, double alpha = 1, double beta = 0}) { dst ??= Mat.empty(); cvRun(() => ccore.cv_convertScaleAbs(src.ref, dst!.ref, alpha, beta, ffi.nullptr)); return 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 - import cv2 import numpy as np # Load an image image = cv2.imread('example.jpg') # Adjust brightness and contrast alpha = 1.5 # Contrast control (1.0-3.0) beta = 50 # Brightness control (0-100) adjusted_image = cv2.convertScaleAbs(image, alpha=alpha, beta=beta) # Save the adjusted image cv2.imwrite('brightness_contrast_example.jpg', adjusted_image) Explanation: Loading the Image: cv2.imread('example.jpg'): Reads the image into a NumPy array.
🌐
Emgu
emgu.com › wiki › files › 3.0.0 › document › html › 42f48437-3b3c-28ec-4fb1-cf6c90374f46.htm
CvInvoke.ConvertScaleAbs Method
public: static void ConvertScaleAbs( IInputArray^ src, IOutputArray^ dst, double scale, double shift )
🌐
Pub.dev
pub.dev › documentation › dartcv_videoio › latest › cv.videoio › convertScaleAbs.html
convertScaleAbs function - cv.videoio library - Dart API
dst, double alpha = 1, double beta = 0, }) { dst ??= Mat.empty(); cvRun(() => cffi.Mat_ConvertScaleAbs(src.ref, dst!.ref, alpha, beta)); return dst; }
🌐
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:
🌐
Kyamagu
kyamagu.github.io › mexopencv › matlab › convertScaleAbs.html
cv.convertScaleAbs - MATLAB File Help
On each element of the input array, the function cv.convertScaleAbs performs three operations sequentially: scaling, taking an absolute value, conversion to an unsigned 8-bit type: