How can I choose multiple File by using UIGETFILE

2 vues (au cours des 30 derniers jours)
dksmt
dksmt le 30 Jan 2015
Commenté : dksmt le 30 Jan 2015
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. :)

Réponse acceptée

dpb
dpb le 30 Jan 2015
...
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.
  1 commentaire
dksmt
dksmt le 30 Jan 2015
BIG THAAAANKS, its WORKS.. I REALLY APRECIATE IT, IT TAKE ME NEARER TO MY GRADUATION DAY.. THANK YOU DUDE! Have you any socmed account? you will be my savior about MATLAB.. :D

Connectez-vous pour commenter.

Plus de réponses (1)

dpb
dpb le 30 Jan 2015
...
[h_LL,h_LH,h_HL,h_HH]=dwt2(rgbimage,'haar');
img=h_LL;
red1=img(:,:,1);
green1=img(:,:,2);
...
Error in embedd (line 13)
green1=img(:,:,2);
This has nothing whatever to do with uigetfile nor the multiselect option therein.
This simply that the array h_LL returned from dwt2 apparently has only one plane.
What is
size(img) % ?
  3 commentaires
dpb
dpb le 30 Jan 2015
You'll have to have a 3D array (image) object from which to select multiple planes; the error is that the 2nd and 3rd planes don't exist in the h_LL output from dwt2
By
size(img)
I mean to look at what the actual returned size is just to confirm what you're getting. Type it in at the command after the error and see what it returns.
I don't have the toolbox nor your data file even if did but if you're expecting a 3D rgb output from dwt2 you're being disappointed, clearly.
dksmt
dksmt le 30 Jan 2015
This error appear when I use the uigetfile=('.jpg','Choose Image','.jpg') command, but when I use imread('image.jpg') the process work well, I don't understand if uigetfile affect the dwt2 proccess.. have you find this error before?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Historical Contests dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by