Colour quantization, uniform quantization

Hi there, I'm working on a project on colour quantization and I'm a little lost with matlab (complete beginner). The method of quantization I'm working on is uniform quantization which splits the red and green axis into 8 segments and the blue axis into 4 giving 256 regions. Then finds the average colour in each region. I'm wondering how I would go about this my code so far for this:
image = imread(ImageName);
red = loadedImg(:,:,1);
green = loadedImg(:,:,2);
blue = loadedImg(:,:,3);
I honestly have no idea as I'm new to matlab! Thanks in advance!

Respuestas (3)

Image Analyst
Image Analyst el 10 de Dic. de 2015

0 votos

Don't call your image "image". Call it loadedImage or something because image() is the name of a built-in function. So then just do a for loop to get the 3D gamut. Attached is an example.

1 comentario

Debs Bradley
Debs Bradley el 10 de Dic. de 2015
Sorry but I don't quite understand what 3D gamut does? Would you mind explaining in terms of the example you provided?

Iniciar sesión para comentar.

Yashwanth
Yashwanth hace alrededor de 5 horas

0 votos

% Uniform Quantization of Piecewise Signal
t1 = -1:0.01:0;
t2 = 0.01:0.01:1;
x1 = t1 + 1;
x2 = t2 - 1;
t = [t1 t2];
x = [x1 x2];
figure;
plot(t,x);
title("Original Signal");
xlabel("time");
ylabel("amplitude");
grid on;
x_max = max(x);
x_min = min(x);
N = 8;
delta = (x_max - x_min)/N;
R = x_min:delta:x_max;
x_h = zeros(1,length(x));
for i = 1:length(x)
for j = 1:(length(R)-1)
if x(i) >= R(j) && x(i) <= R(j+1)
x_h(i) = R(j) + (delta/2);
end
end
end
figure;
stem(t,x_h);
title("Quantization Level");
xlabel("time");
ylabel("level");
grid on;
figure;
stem(x,x_h);
title("Transfer Characteristics");
xlabel("Input Signal");
ylabel("Quantized Signal");
grid on;
Yashwanth
Yashwanth hace alrededor de 5 horas

0 votos

x = random('norm',2,sqrt(5),1,10000);
subplot(3,1,1)
stem(x)
title("Gaussian signal")
xlabel("time")
ylabel("amplitude")
N = 8;
[R,C] = lloyds(x,N);
[index,q] = quantiz(x,R,C);
subplot(3,1,2)
stem(q)
title("Quantization Level")
xlabel("Number of Random Variables")
ylabel("q")
subplot(3,1,3)
stem(x,q)
title("Transfer Characteristics")
xlabel("x")
ylabel("q")

Preguntada:

el 10 de Dic. de 2015

Respondida:

hace alrededor de 20 horas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by