Gray image quantization

2 Ansichten (letzte 30 Tage)
Alan AF
Alan AF am 10 Feb. 2012
Bearbeitet: Erik am 8 Okt. 2013
I am trying to quantize an image into 12 bit intensity using the below code:
R2D = mat2gray(R2D); % intensity between [0,1] Double
R2D = double(uencode(R2D,12)); % intensity between [0,2^12] integer
PIC = mat2gray(R2D); % intensity between [0,1] Double
imshow(pic);
the problem is in 'uencode' function , the input must be in the range of [-1,1], is there a way to do that quantization for input values between [0,1]? may be some changes to the 'uencode' will do job :)
Many thanks

Akzeptierte Antwort

Alan AF
Alan AF am 10 Feb. 2012
Thank you, I found the Solution:
R2D = mat2gray(R2D);
[R2D8,map] = gray2ind(R2D,128);
pic = ind2gray(R2D8,map);
pic = mat2gray(pic);
imshow(pic);
  1 Kommentar
Image Analyst
Image Analyst am 10 Feb. 2012
This does 128 gray levels, not 4096.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 10 Feb. 2012
How about using code like:
actualMin = double(min(min(imgOriginal)));
actualMax = double(max(max(imgOriginal)));
slope = (desiredMax - desiredMin) / (double(actualMax) - double(actualMin));
scaledImage = slope * (double(imgOriginal) - actualMin) + desiredMin;
  2 Kommentare
Alan AF
Alan AF am 10 Feb. 2012
Thanks for your reply
Actually my intention is to Quantize the Image (i.e store every pixel into an 12 bit integer), is there a way to do that?
many thanks :)
Image Analyst
Image Analyst am 10 Feb. 2012
I didn't think that was your intention because at the end you called mat2gray() which forces it into a 0-1 range, which pretty much wipes out quantization - not quite but for most intents and purposes it does. And the quantized intermediate images, you didn't do anything with.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by