I have the following code:
img_rgb = imread('IMD037.bmp');img_gray=rgb2gray(img_rgb);[rows, cols] = size(img_gray);%%%Converting image in HSV domain and then calculate Histogram
img_hsv = rgb2hsv(img_rgb);% % splitting HSV image into h, s & v channels
h = img_hsv(:, :, 1);s = img_hsv(:, :, 2);v = img_hsv(:, :, 3);% quantization levels
h_level=16; s_level=4;v_level=4;% %%%%%%%%%image quantization
max_h=max(h(:));min_h=min(h(:));max_s=max(s(:));min_s=min(s(:));max_v=max(v(:));min_v=min(v(:));range_h=max_h-min_h;range_s=max_s-min_s;range_v=max_v-min_v;%%%%%%%%%%%%%%FOR Hue
scale_h=(h_level-1)/range_h;%q=round(x*scale)/scale;
for row = 1:size(h, 1) for col = 1 : size(h, 2) quantizedValueForH(row, col) = ceil(h(row, col)*scale_h); endend%%%%%%%%%%%%%%%For Saturation
scale_s=(s_level-1)/range_s;%q=round(x*scale)/scale;for row = 1:size(s, 1) for col = 1 : size(s, 2) quantizedValueForS(row, col) = ceil(s(row, col)*scale_s); % 16*h(i,j)/max of h
endend%%%%%%%%%%%%%%%%For Value
scale_v=(v_level-1)/range_v;%q=round(x*scale)/scale;for row = 1:size(s, 1) for col = 1 : size(s, 2) quantizedValueForV(row, col) = ceil(s(row, col)*scale_v); % 16*h(i,j)/max of h endend%%%%%Histogram
figure%vec_bin_edges=0:15;
%hist3([quantizedValueForH quantizedValueForS], {0 15});
hist(quantizedValueForH)figurehist(quantizedValueForS)figurehist(quantizedValueForV)
Best Answer