how can i quantize an image

5 Ansichten (letzte 30 Tage)
nadia
nadia am 21 Apr. 2017
Beantwortet: Walter Roberson am 21 Apr. 2017
Hi, I want to quantize an image, this image is uint8 and I want to quantize it to 16 levels and for this aim I want to use bitset, I do it but this bit dose not change? can you help me?
img=uint8(imread('lena.bmp'));
for i=1:size(img,1)
for j=1:size(img,2)
bitset(img(i,j),8,0);
bitset(img(i,j),7,0);
bitset(img(i,j),6,0);
bitset(img(i,j),5,0);
end
end

Antworten (1)

Walter Roberson
Walter Roberson am 21 Apr. 2017
You have to assign the output of bitset to something.
I would suggest, by the way, that you consider bitand
img(i,j) = bitand(img(i,j), uint8(240));
You can do the whole thing without a loop:
newimg = bitand(img, uint8(240));

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by