converting floating point value to integer
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have an image in floating point value,i have to convert it into integer ,can anyone suggest an idea please
I have values for example ,i have taken some pixels from my image,and my whole image pixels values in these ranges only,now i want to convert this floating point into an integer value and i want to read image from those intteger value pixels
0.0004 0.0004 0.0004 0.0003 0.0003 0.0002
0.0006 0.0005 0.0005 0.0005 0.0004 0.0003
0.0008 0.0007 0.0007 0.0007 0.0006 0.0005
6 Kommentare
Jan
am 14 Dez. 2011
And again: What is the range of the input (max value - min value) and what is the wanted range for the output?
Akzeptierte Antwort
Andrei Bobrov
am 14 Dez. 2011
A = [ 0.0004 0.0004 0.0004 0.0003 0.0003 0.0002
0.0006 0.0005 0.0005 0.0005 0.0004 0.0003
0.0008 0.0007 0.0007 0.0007 0.0006 0.0005]
[a b c] = unique(A);
B = im2uint8(linspace(0,1,numel(a)))
out = reshape(B(c),size(A))
imagesc(out)
ADD
B = linspace(0,1,numel(a))
out = reshape(B(c),size(A))
image(bsxfun(@plus,out,zeros(1,1,3)))
4 Kommentare
Weitere Antworten (1)
Jan
am 14 Dez. 2011
A = [0.0004 0.0004 0.0004 0.0003 0.0003 0.0002;
0.0006 0.0005 0.0005 0.0005 0.0004 0.0003;
0.0008 0.0007 0.0007 0.0007 0.0006 0.0005];
B = uint8((A - min(A(:))) * (255 / (max(A(:) - min(A(:))))));
0 Kommentare
Siehe auch
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!