rounding problem after decimal point in image processing
3 views (last 30 days)
Show older comments
that is the last portion of my first program-
cD1=idwt2(new,cHH,cVV,cDD,'haar');
cD1(cD1<.0000000001 & cD1>-tol) = 0;
disp('cD1');
disp(cD1);
final1=idwt2(cA,cH,cV,cD1,'haar');
final=cat(3,final1,final2,final3);
imwrite(uint8(final),'Image.png');
here final2 & final3 are same as final1,just for red,green & blue channel respectively. i am displaying the cD which gives a floating point number.
& that is the first portion of my second code-
rgb=imread('Image.png');
red1=rgb(:,:,1);
green1=rgb(:,:,2);
blue=rgb(:,:,3);
[cA,cH,cV,cD]=dwt2(red1,'haar');
cD(cD<.0000000001 & cD>-tol) = 0;
disp('new cD');
disp(cD);
and this time the cD is giving the rounding answer after decimal point as u can seen the provided screen shoot image below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148244/image.jpeg)
upper portion is given after the first code & lower portion is given by the second code.
0 Comments
Answers (1)
David Young
on 20 Aug 2015
If you convert to class uint8 you lose everything after the decimal point. Is that perhaps the problem? If so, don't cast to uint8, and use save and load to store and recover your data instead of imwrite and imread.
4 Comments
Walter Roberson
on 20 Aug 2015
None of the common image file formats support floating point, only integer. If your technique requires hiding in floating point then you are doomed to disappointment. You might be able to produce a floating point TIFF file if you use the TIFF class, but the moment anyone saves the image in any other format the floating point would be converted to integer.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!