rounding problem after decimal point in image processing
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
David Young
2015-8-20
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 个评论
Walter Roberson
2015-8-20
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!