rounding problem after decimal point in image processing

조회 수: 3 (최근 30일)
anika hossain
anika hossain 2015년 8월 19일
댓글: Walter Roberson 2015년 8월 20일
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
upper portion is given after the first code & lower portion is given by the second code.

답변 (1개)

David Young
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
anika hossain
anika hossain 2015년 8월 20일
there is no error message, it is losing value. my project is on image watermarking. the first portion code i gave above is for embedding & next one for extraction. i am mainly tring to hide my watermark bit in the hosts floating point. so floating point is very important for that. when i am using the output from first one as the input of extraction it is giving the rounding answer after point & i am losing the value as u can seen in the image provided.
Walter Roberson
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!

Translated by