converting floating point value to integer

조회 수: 6 (최근 30일)
kash
kash 2011년 12월 14일
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
Jan
Jan 2011년 12월 14일
And again: What is the range of the input (max value - min value) and what is the wanted range for the output?
kash
kash 2011년 12월 14일
max val=5.2967e-004
min val=4.1036e-012
the output range is 0-255

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 12월 14일
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
kash
kash 2011년 12월 14일
thanks andrei
kash
kash 2011년 12월 14일
Andrei can u tell hoe electromagnetism algorithm works with image processing please

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2011년 12월 14일
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(:))))));

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by