How can I correction hue values of image
3 次查看(过去 30 天)
显示 更早的评论
How can I correction hue values of image
采纳的回答
Image Analyst
2016-10-17
You need to snap an image of a color standard with known color values. The usual standard is the x-rite Color Checker Chart. Then you have known XYZ values. You can use least squares to derive a transform to convert your RGB values, of the color chips on a picture of that chart that you have taken, into XYZ values. Then you can use analytical formulas to convert XYZ into LAB or other calibrated color spaces.
4 个评论
Image Analyst
2016-10-17
Try this:
clc;
clearvars;
close all;
workspace;
fontSize = 15;
format compact
format short g;
rgbImage = imread('peppers.png');
subplot(2, 4, 1);
imshow(rgbImage);
axis on;
title('Original Image', 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
hsvImage = rgb2hsv(rgbImage);
hImage = hsvImage(:, :, 1);
sImage = hsvImage(:, :, 2);
vImage = hsvImage(:, :, 3);
subplot(2, 4, 2);
imshow(hImage, [0, 1]);
title('Hue Image', 'FontSize', fontSize);
subplot(2, 4, 3);
imshow(sImage, []);
title('Saturation Image', 'FontSize', fontSize);
subplot(2, 4, 4);
imshow(vImage, []);
title('Value Image', 'FontSize', fontSize);
someFactor = 1.6; % or whatever.
% Use mod to "wrap around" values more than 1.
hImageNew = mod(hImage * someFactor, 1);
subplot(2, 4, 6);
imshow(hImageNew, [0, 1]);
title('New Hue Image', 'FontSize', fontSize);
% Create new image
hsvImage = cat(3, hImageNew, sImage, vImage);
% Convert back to RGB color space.
rgbImageNew = hsv2rgb(hsvImage); % It's double in the range of 0-1 here.
% Convert to uint8 in the range 0-255
rgbImageNew = uint8(255 * mat2gray(rgbImageNew));
subplot(2, 4, 5);
imshow(rgbImageNew);
title('Changed Image', 'FontSize', fontSize);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!