How can adjust luminosity with HSV?

1 view (last 30 days)
Hello friends, I have a set of 20 color images and I want to implement some operations.but before working on these images, I must homogenize the luminance (HSV) someone can suggest me a way to do this. I have done the following code, anda I want get the array of all image luminance average, but my problem is since the image is obtained by a for loop when a try change the image in rgb2hsv give me this error
if true
% code
Error using rgb2hsv (line 59)
MAP must be a Mx3 array.
Error in teste (line 15)
hsv = rgb2hsv(a)
end
the code :
if true
% code
clear all, close all, clc;
imgDir = dir(fullfile('','/database/*.jpg'));
outDir = '/resultados/';
imgDimensao = length(imgDir);
data =zeros(1,imgDimensao)
for x = 1:length(imgDir)
handles.images{x}=imread(fullfile('','/database/',imgDir(x).name));
a = imgDir(x).name;
hsv = rgb2hsv(a)
a = mean2(a);
data(x) = a ;
end
data
mean2(data
end

Accepted Answer

Image Analyst
Image Analyst on 16 Jun 2015
THe badly-named "a" must be an RGB image, not a filename string. And don't use hsv as an image name since it's a built-in function.
rgbImage =imread(fullfile('','/database/',imgDir(x).name));
hsvImage = rgb2hsv(rgbImage);
meanValues(x) = mean2(hsvImage (:,:, 3));
After the loop, you can get the overall mean by doing this:
meanV = mean(meanValues);

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!