You can try:
gray = cv2.convertScaleAbs(sobely, alpha=255/sobely.max())
plt.imshow(gray, cmap='gray')
Answer from sim0ne on Stack OverflowShimat
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 )
Top answer 1 of 2
6
You can try:
gray = cv2.convertScaleAbs(sobely, alpha=255/sobely.max())
plt.imshow(gray, cmap='gray')
2 of 2
4
You can accept the default arguments for the alpha and beta arguments, so the call is simply:
graySobel = cv.convertScaleAbs(sobely)
Then you can call adaptiveThreshold:
thres = cv2.adaptiveThreshold(graySobel, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY, 73, 2)
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
TutorialsPoint
tutorialspoint.com › article › how-to-change-the-contrast-and-brightness-of-an-image-using-opencv-in-python
How to change the contrast and brightness of an image using OpenCV in Python?
March 26, 2026 - In OpenCV, to change the contrast and brightness of an image we use cv2.convertScaleAbs() method.
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¶ ·
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()
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
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)
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
Opencv
opencv.org.cn › opencvdoc › 2.3.2 › html › modules › core › doc › operations_on_arrays.html
Operations on Arrays — OpenCV 2.3.2 documentation
Python: cv.ConvertScaleAbs(src, dst, scale=1.0, shift=0.0) → None¶
OpenCV
docs.opencv.org › 3.4.20 › d2 › de8 › group__core__array.html
OpenCV: Operations on arrays
On each element of the input array, the function convertScaleAbs performs three operations sequentially: scaling, taking an absolute value, conversion to an unsigned 8-bit type:
