How can adjust luminosity with HSV?

1 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2015-6-16
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by