How can i save an image and read it again without change its value ?

6 次查看(过去 30 天)
im doing watermarking image using DWT and got problem about the value change when i try to read the watermarked image
imwrite(Watermarkedimage_final ,'iwater.bmp');
x=imread('iwater.bmp');
x=im2double(x);
[F11,F22]= wfilters('haar', 'd');
[a b c d]=dwt2(x,'haar','d');
[aa bb cc dd]=dwt2(a,'haar','d');
[aaa bbb ccc ddd]=dwt2(aa,'haar','d');
recovered_image=imadjust(recovered_image);
imshow(uint8(recovered_image),[]);
imwrite(recovered_image ,'bmp.bmp');

回答(3 个)

Image Analyst
Image Analyst 2017-4-2
Watermarkedimage_final and the badly-named "x" will have the same values because BMP is a lossless format.
Likewise, if you use imread to read in the badly-named 'bmp.bmp' then the recalled image will have the same values as uint8(recovered_image).

Walter Roberson
Walter Roberson 2017-4-2
Sorry, No, MATLAB does not support any double precision floating point image formats. It supports single precision TIFF; see https://www.mathworks.com/matlabcentral/answers/7184-how-can-i-write-32-bit-floating-point-tifs-with-nans#comment_15023 .
TIFF 6.0 added support for IEEE double precision but MATLAB is not able to write those out.
  3 个评论
Walter Roberson
Walter Roberson 2017-4-5
The TIFF class can only handle single precision. The TIFF file format revision 6 and later can handle double precision, but imwrite() and the TIFF class cannot write version 6 TIFF files.
In other words, if you need to be able to write the watermarked data as an image file, you have three choices:
  1. find a way to write TIFF 6 double precision files -- which your display program probably would not be able to display anyhow; or
  2. use an integer-to-integer DWT instead of a double precision DWT; or
  3. modify the values in such as way that after writing to file and reading back in the changed data is reliably distinguishable from the original values and can be processed to extract the watermark.
LSB (Least Significant Bit) modifications of the double precision wavelet transform are not enough to be able make recoverable changes.
Walter Roberson
Walter Roberson 2019-1-21
There is a File Exchange contribution that claims to be able to write double precision TIFF.

请先登录,再进行评论。


budi agung
budi agung 2017-4-5
this is my code
clc
close all
%host
cover=imresize(imread('host.jpg'),[256 256]);
%rgbimage=rgb2gray(rgbimage);
cover=im2double(cover);
[F1,F2]= wfilters('haar', 'd');
figure;imshow(cover);title('original color image');
[h_LL,h_LH,h_HL,h_HH]=dwt2(cover,'haar', 'd');
[h_LL2,h_LH2,h_HL2,h_HH2]=dwt2(h_LL,'haar', 'd');
[nRow nCol noDim] = size(h_LL2);
water=imresize(imread('watermark.jpg'),[nRow nCol]);
%water=rgb2gray(water);
water=im2double(water);
%watermarking
newhost_LL = h_LL2 +0.1*water;
%output
hasil1=idwt2(newhost_LL,h_LH2,h_HL2,h_HH2,'haar', 'd');
hasil1=idwt2(hasil1,h_LH,h_HL,h_HH,'haar', 'd');
figure;imshow(hasil1);title('Watermarked image');
imwrite(hasil1,'Watermarked.bmp','bmp');
%extracted
watermarked=imread('watermarked.bmp');
watermarked=im2double(watermarked);
[wm_LL,wm_LH,wm_HL,wm_HH]=dwt2(watermarked,'haar', 'd');
[wm_LL2,wm_LH2,wm_HL2,wm_HH2]=dwt2(wm_LL,'haar', 'd');
newwatermark_LL= (wm_LL2-h_LL2)/0.1;
figure;imshow(newwatermark_LL);title('Extracted watermark');
%imwrite(newwatermark_LL,'EeweWatermark.bmp');
i didn't got the same value the image that i write in .bmp and the image that i read in .bmp
  17 个评论
Shoriful Islam Shuvo
编辑:Shoriful Islam Shuvo 2018-7-12
It is not mandatory for me to use mp4 video format.so i have tried uncompressed avi format and looks like it is working
Image Analyst
Image Analyst 2018-7-12
The demos in my files attached to my prior comment above (and again, here) handle .avi. Did you try that?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Wavelet Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by