MATLAB: How to choose multiple File by using UIGETFILE

image choosingmultipleuigetfilewatermark

I am using UIGETFILE to open multiple file in my Watermarking script, the script look like this:
%host
rgbimage=uigetfile('*.jpg,*.bmp','Choose Host Images','*.jpg');
figure;
imshow(rgbimage);
title('Original Picture');
[h_LL,h_LH,h_HL,h_HH]=dwt2(rgbimage,'haar');
img=h_LL;
red1=img(:,:,1);
green1=img(:,:,2);
blue1=img(:,:,3);
[U_imgr1,S_imgr1,V_imgr1]= svd(red1);
[U_imgg1,S_imgg1,V_imgg1]= svd(green1);
[U_imgb1,S_imgb1,V_imgb1]= svd(blue1);
%watermark
rgbimage=uigetfile('*.jpg,*.bmp','Choose Host Images','*.jpg');
figure;
imshow(rgbimage);
title('Watermark (to be embedded)');
[w_LL,w_LH,w_HL,w_HH]=dwt2(rgbimage,'haar');
img_wat=w_LL;
red2=img_wat(:,:,1);
green2=img_wat(:,:,2);
blue2=img_wat(:,:,3);
[U_imgr2,S_imgr2,V_imgr2]= svd(red2);
[U_imgg2,S_imgg2,V_imgg2]= svd(green2);
[U_imgb2,S_imgb2,V_imgb2]= svd(blue2);
% watermarking
S_wimgr=S_imgr1+(0.10*S_imgr2);
S_wimgg=S_imgg1+(0.10*S_imgg2);
S_wimgb=S_imgb1+(0.10*S_imgb2);
wimgr = U_imgr1*S_wimgr*V_imgr1';
wimgg = U_imgg1*S_wimgg*V_imgg1';
wimgb = U_imgb1*S_wimgb*V_imgb1';
wimg=cat(3,wimgr,wimgg,wimgb);
newhost_LL=wimg;
%output
rgb2=idwt2(newhost_LL,h_LH,h_HL,h_HH,'haar');
imwrite(uint8(rgb2),'Watermarkedss.jpg');
figure;imshow(uint8(rgb2));title('Watermarked Picture');
first file choosing works well, but i get error like:
Index exceeds matrix dimensions.
Error in embedd (line 13)
green1=img(:,:,2);
help slove the problem, thanks before. 🙂

Best Answer

...
rgbimage=uigetfile('*.jpg,*.bmp','Choose Host Images','*.jpg');
imshow(rgbimage);
...uigetfile=('.jpg','Choose Image','.jpg') command, but when I use imread('image.jpg') the process work[s]...
uigetfile simply returns the filename you have selected; it does NOT open the file. You still need the imread call to read the file except pass it the filename you selected.
fname=uigetfile('*.jpg,*.bmp','Choose Host Images','*.jpg');
rgbimage=imread(fname);
See
doc uigetfile
for the details and examples of using it...
Sorry I missed noticing that earlier.