在 MATLAB 中增加和减少图像的亮度
图像的照度程度称为亮度。物体发出的光量决定了该物体的亮度。如果一个物体被放置在一个黑暗的房间里,那么这个物体发出的光就会非常少,因此我们无法正确地看到这个物体。现在,我们所说的数字图像中的亮度是什么意思?它被定义为图像像素的强度级别。我们知道,0 强度表示暗像素,1 强度表示白色像素。因此,亮度可以说是图像所有像素的平均强度值。
Syntax:
image_var = imread(“path of image”);
image = image – C; where C is constant, like 50.
image = image + C; where C is constant, like 50.
imtool(image_var, [ ]);
示例 1:
Matlab
% MATLAB code for read the image
% and convert into dark and bright images.
org_image=imread("lady_with_hat.jfif");
dark_image=uint8(org_image-50);
bright_image=uint8(org_image+50);
% Bring the all three images to see
% the difference in brightness.
imtool(org_image, []);
imtool(dark_image, []);
imtool(bright_image, []);
Matlab
% MATLAB code for read the colored image
% and convert into dark and bright images.
org_image=imread("logo.png");
dark_image=uint8(org_image-50);
bright_image=uint8(org_image+50);
% Bring the all three images to see
% the difference in brightness.
imtool(org_image, []);
imtool(dark_image, []);
imtool(bright_image, []);
输出:
示例 2:
MATLAB
% MATLAB code for read the colored image
% and convert into dark and bright images.
org_image=imread("logo.png");
dark_image=uint8(org_image-50);
bright_image=uint8(org_image+50);
% Bring the all three images to see
% the difference in brightness.
imtool(org_image, []);
imtool(dark_image, []);
imtool(bright_image, []);
输出:
为了增加亮度,我们必须增加每个像素的强度。图像是像素值的集合。因此,它们本质上是可加的。我们可以为每个像素值添加一个常量。为了降低亮度,我们可以从图像的所有像素中减少一个常数值。