my code is given below-
w=imread('win.png');%its a 32X32 picture
for i=1:32
for j=1:32
wrr(i,j)=w(i,j)*.02;
end
end
disp('wrr');
disp(wrr);
the problem is- its rounding the pixel values,like if w(i,j)=178 then after multiplication with .02 wrr(i,j)=4 where it should be 3.56. i need the floating point for further work. can anyone help?

댓글 수: 7

anika hossain
anika hossain 2015년 8월 19일
sorry to bother again...but having kind of same problem.now its rounding or something like that after the point. for easy understanding i am attaching image of it. upper side of image shows the value first found which is accurate & the lower side of image shows the value found when reading it in another file-
another one-
Star Strider
Star Strider 2015년 8월 19일
I’m completely lost. I have no idea what you’re doing.
anika hossain
anika hossain 2015년 8월 19일
for my project i have to use the values that i get form running 1st program to the 2nd program. so when i am displaying the values of 1st one, it gives me the values u are watching in the upper portion of the image & when i am reading it to 2nd program & displaying it gives the result u are watching in the lower portion of the image.no operation is done in between them
Star Strider
Star Strider 2015년 8월 19일
Guessing what your code is doing is extremely difficult for me. Perhaps posting it would help.
Walter Roberson
Walter Roberson 2015년 8월 19일
How are you doing the writing to the file?
Star Strider
Star Strider 2015년 8월 19일
I’m not familiar enough with wavelets or watermarking to answer. Please post this as a new Question, so those with the necessary background can see it and respond to it.
I will delete it from this Question in a few days.
anika hossain
anika hossain 2015년 8월 19일
ok

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

 채택된 답변

Star Strider
Star Strider 2015년 8월 15일
편집: Star Strider 2015년 8월 15일

0 개 추천

You need to cast ‘w’ as double before you do the calculations. You can recast it as whatever it was previously to save it later.
The easiest way might be:
w=imread('win.png');%its a 32X32 picture
wrr = double(w);
for i=1:32
for j=1:32
wrr(i,j)=wrr(i,j)*.02;
end
end
disp('wrr');
disp(wrr);
That preserves the original ‘w’ if you want to do that.
However the easiest way to do what you want is simply:
w=imread('win.png');%its a 32X32 picture
wrr = double(w) * 0.02;

댓글 수: 4

anika hossain
anika hossain 2015년 8월 15일
it works...thanks
Star Strider
Star Strider 2015년 8월 15일
My pleasure!
Image Analyst
Image Analyst 2015년 8월 19일
I don't know why MATLAB doesn't "promote" variables to the more general class like other languages. If you do b=a*0.1234, and "a" is uint8 then b will be uint8. I think most languages would make b double.
Guillaume
Guillaume 2015년 8월 19일
Yes, matlab is probably on its own in having implicit narrowing (lossy) conversion of numeric types. All other languages either only allow implicit widening conversion (no loss, narrowing conversion must be explicitly requested), or simply don't allow implicit conversions. See this nice explanation in the doc of Julia.
I believe I saw the reasoning behind mathworks decision somewhere but like many others of their decision I think it's bonkers.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 GPU Computing에 대해 자세히 알아보기

질문:

2015년 8월 15일

댓글:

2015년 8월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by