필터 지우기
필터 지우기

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

조회 수: 8 (최근 30일)
budi agung
budi agung 2017년 4월 2일
댓글: Walter Roberson 2019년 1월 21일
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).
  댓글 수: 2
budi agung
budi agung 2017년 4월 2일
ok thanks.
can i imwrite image in double data type ?
Image Analyst
Image Analyst 2017년 4월 2일
Use save() to save it to a .mat file.

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


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일
편집: 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?

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

Community Treasure Hunt

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

Start Hunting!

Translated by