MATLAB Answers

0

How to detect brightness of the image and adjust automatically?

Asked by Shu Yi Ho on 7 Aug 2019
Latest activity Answered by Sai Bhargav Avula on 12 Aug 2019
I have a folder of images which contains different brightness images. From this folder, I want to identify those that are too bright or dull and automatically make adjustment to them. As for the rest of the images that meet the criteria will be left alone.
Thanks in advance.

  0 Comments

Sign in to comment.

1 Answer

Answer by Sai Bhargav Avula on 12 Aug 2019
 Accepted Answer

If the files are sequentially named, then you can read them using the following code.
path_directory='folder_name'; % 'Folder name'
original_files=dir(['path_directory '/*.jpg']); % for this case jpg
for k=1:length(original_files)
filename=fullfile('path_directory', original_files(k).name);
image_orginal=imread(filename); % Image read is done
%%Image Operation as per your work
end
The brightness of the image can be calculated by your definition of brightness. For example it can be calculated by the V color of the HSV color space
This goes below “%%Image Operation as per your work” in the code given above.
hsvImage = rgb2hsv(filnename); % HSV color map convertion
brightness = hsvImage(:, 3); % calculating the
Other way would be to find the mean of the image
brightness = mean2(filename);
Using the brightness values the adjustments can be made for each image.

  0 Comments

Sign in to comment.