ColorHistogram
2016-08-23
0 0 0
no vote
Other
Earn points
close all;
clear all
clc;
I = imread('lavender.jpg');
imshow(I),figure
I = im2double(I);
[index,map] = rgb2ind(I);
pixels = prod(size(index));
hsv = rgb2hsv(map);
h = hsv(:,1);
s = hsv(:,2);
v = hsv(:,3);
%Finds location of black and white pixels
darks = find(v < .2)';
lights = find(s < .05 & v > .85)';
h([darks lights]) = -1;
%Gets the number of all pixels for each color bin
black = length(darks)/pixels;
white = length(lights)/pixels;
red = length(find((h > .9167 | h <= .083) & h ~= -1))/pixels;
yellow = length(find(h > .083 & h <= .25))/pixels;
green = length(find(h > .25 & h <= .4167))/pixels;
cyan = length(find(h > .4167 & h <= .5833))/pixels;
blue = length(find(h > .5833 & h <= .75))/pixels;
magenta = length(find(h > .75 & h <= .9167))/pixels;<
clear all
clc;
I = imread('lavender.jpg');
imshow(I),figure
I = im2double(I);
[index,map] = rgb2ind(I);
pixels = prod(size(index));
hsv = rgb2hsv(map);
h = hsv(:,1);
s = hsv(:,2);
v = hsv(:,3);
%Finds location of black and white pixels
darks = find(v < .2)';
lights = find(s < .05 & v > .85)';
h([darks lights]) = -1;
%Gets the number of all pixels for each color bin
black = length(darks)/pixels;
white = length(lights)/pixels;
red = length(find((h > .9167 | h <= .083) & h ~= -1))/pixels;
yellow = length(find(h > .083 & h <= .25))/pixels;
green = length(find(h > .25 & h <= .4167))/pixels;
cyan = length(find(h > .4167 & h <= .5833))/pixels;
blue = length(find(h > .5833 & h <= .75))/pixels;
magenta = length(find(h > .75 & h <= .9167))/pixels;<
matlab
ColorHistogram
Related Source Codes
GMSK Linear Receiver
0
0
no vote
NSGA-II algorithm
0
0
no vote
NSGA-III multi-objective optimization algorithm
0
0
no vote
Compressed sensing example
0
0
no vote
CFAR detector example
0
0
no vote
No comment