how to enhance blue color alone of an image?
Ältere Kommentare anzeigen
how to enhance blue color alone of an image?
2 Kommentare
Jan
am 13 Sep. 2012
What exactly does "enhance" mean?
Dorothy Lopez
am 2 Aug. 2016
I think he want to tone pictures to blue color images, adding more blue hues on the photos. From my knowledge, many tools can do it, famous one are Gimp, On1, PS, LR.....
Akzeptierte Antwort
Weitere Antworten (2)
Image Analyst
am 13 Sep. 2012
Bearbeitet: Image Analyst
am 13 Sep. 2012
I think you'll find this demo illustrates it very well:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'football.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage, []);
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Convert to hsv color space.
hsv = rgb2hsv(rgbImage);
% Display the color channels.
hueImage = hsv(:, :, 1);
saturationImage = hsv(:, :, 2);
valueImage = hsv(:, :, 3);
subplot(2, 2, 2);
imshow(hueImage, []);
title('Hue Channel', 'FontSize', fontSize);
subplot(2, 2, 3);
imshow(saturationImage, []);
title('Saturation Channel', 'FontSize', fontSize);
subplot(2, 2, 4);
imshow(valueImage, [])
title('Value Channel', 'FontSize', fontSize);
% Look at the histogram of the hue channel
% so we can see where the blue is
[pixelCounts values] = hist(hueImage, 500);
figure;
subplot(2, 2, 1);
bar(values, pixelCounts);
title('Histogram of Hue Channel', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Blue looks like it's in the 0.4 to 0.7 region.
% Amplify that by increasing saturation for those pixels.
% Find blue pixels. They have to have the right hue but not be too bright.
bluePixels = hueImage > 0.4 & hueImage < 0.7 & valueImage < 0.8;
subplot(2, 2, 2);
imshow(bluePixels);
title('Map of Blue Pixels', 'FontSize', fontSize);
% Multiply the saturation channel by 1.5 for those pixels.
saturationImage(bluePixels) = saturationImage(bluePixels) * 3.5;
subplot(2, 2, 3);
imshow(saturationImage);
title('New Saturation Channel', 'FontSize', fontSize);
% Combine back to form new hsv image
hsvImage = cat(3, hueImage, saturationImage, valueImage);
% Convert back to RGB color space.
rgbImage = hsv2rgb(hsvImage);
subplot(2, 2, 4);
imshow(rgbImage);
title('RGB Image with Enhanced Blue', 'FontSize', fontSize);
6 Kommentare
Image Analyst
am 21 Sep. 2012
I'm surprised you didn't think this answer worked. Did you even try it?
Yicheng
am 24 Mai 2014
I like this answer!!!!!!!
PhD Problems
am 30 Jul. 2019
@Image Analyst,
Can you please clarify how you selected the blue region from the bar graph?
Here is the generated graph for the sample footbal image used in your cade:

How did you find the blue region to be from 0.4 to 0.7 based on the above? If I wanted to select the region for the brown/orange football, how would I select that color regions from the above graph?
Thank you
Image Analyst
am 31 Jul. 2019
Look at my avatar to see the color space. Hues for blue will be around 270 degrees, more or less.
PhD Problems
am 31 Jul. 2019
Thank you, that makes sense, but in your code you relied on the above graph and histogram to choose the region of 0.4 to 0.7. I just dont understand how?
As I need to enhance the yellow colour in my sample and based on your profile avatar I can see that that if I want to target yellow, it will be around 0 degrees, right? But how does that transfer to the graph/histogram above?
Thanks
Image Analyst
am 1 Aug. 2019
Well I knew that blue was in that range. Yellow is straight up, around 90 degrees. So you can choose a range of about 45 to 135 degrees or so. Divide by 360 to get values in the range 0-1.

Jan
am 13 Sep. 2012
RGB = rand(200, 100, 3);
Blue = RGB(:, :, 3);
enhancedBlue = max(Blue + 0.1, 1.0); % Or whatever
RGB(:, :, 3) = enhancedBlue;
Kategorien
Mehr zu Blue finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!