From: shilpa khinvasara on
Sir
i have the following code for histogram quantization

clc;
close all;
% Open a standard MATLAB demo image.
rgbImage = imread('test.jpg');

% Display the original image.
figure;
subplot(2, 4, 1);
imshow(rgbImage, []);
title('Original RGB image');

% Convert to HSV color space
hsv = rgb2hsv(rgbImage);

% Extract out the individual channels.


h=hsv(:,:,1);
s=hsv(:,:,2);
v=hsv(:,:,3);


h=h*360;
H=zeros(size(hsv,1),size(hsv,2));
H(h>=0&h<=20)=0;
H(h>=21&h<=40)=1;
H(h>=41&h<=65)=2;
H(h>=66&h<=85)=3;
H(h>=86&h<=105)=4;
H(h>=106&h<=125)=5;
H(h>=126&h<=145)=6;
H(h>=146&h<=165)=7;
H(h>=166&h<=185)=8;
H(h>=186&h<=205)=9;
H(h>=206&h<=225)=10;
H(h>=226&h<=245)=11;
H(h>=246&h<=265)=12;
H(h>=266&h<=285)=13;
H(h>=286&h<=305)=14;
H(h>=306&h<=325)=15;
H(h>=326&h<=345)=16;
H(h>=346&h<=355)=17;



S=zeros(size(hsv,1),size(hsv,2));
S(s>=0&s<=0.2)=0;
S(s>0.2&s<=0.7)=1;
S(s>0.7&s<=1)=2;


V=zeros(size(v));
V(v>=0&v<=0.2)=0;
V(v>0.2&v<=0.7)=1;
V(v>0.7&v<=1)=2;

q=9*H+3*S+V;


hist(q);

is it ok?

what if i have to include the following conditions
if v<0.25
q=0
else if v>0.25
and s<0.06
q=1
0.06<s<0.12
q=2
s<0.2
q=3
else
q=9*H+3*S+V;