<< addWeighted Image operations minMaxLoc >>

scicv >> Image operations > convertScaleAbs

convertScaleAbs

Scales, calculates absolutes and convert an image to 8-bit image

Syntax

img_out = convertScaleAbs(img[, alpha[, beta]])

Parameters

img

Image (Mat).

alpha

Optional scale factor (double, default 1).

beta

Optional scalar added to the scaled values (double, default 0).

img_out

Output image (Mat).

Description

convertScaleAbs scales, caclulates the the absolute value of an image, as following:

$img = |alpha*img + beta$|

Then the result is converted to a 8-bit image

Examples

scicv_Init();

img = imread(getSampleImage("lena.jpg"), CV_LOAD_IMAGE_GRAYSCALE);

// First order derivative on x, kernel size 3
img_grad_x = Sobel(img, CV_16S, 1, 0, 3);
img_grad_abs_x = convertScaleAbs(img_grad_x);

// First order derivative on x, kernel size 3
img_grad_y = Sobel(img, CV_16S, 0, 1, 3);
img_grad_abs_y = convertScaleAbs(img_grad_y);

// Calculates the gradient image
img_grad = addWeighted(img_grad_abs_x, 0.5, img_grad_abs_y, 0.5, 0);
matplot(img_grad);

delete_Mat(img);
delete_Mat(img_grad_x);
delete_Mat(img_grad_abs_x);
delete_Mat(img_grad_y);
delete_Mat(img_grad_abs_y);
delete_Mat(img_grad);

See also


Report an issue
<< addWeighted Image operations minMaxLoc >>