Filter löschen
Filter löschen

Unable to perform assignment because the size of the left side is 1-by-7 and the size of the right side is 1-by-5.

1 Ansicht (letzte 30 Tage)
I want replace the 5 LSB of the 'c' image by the 5 MSB of the 's' image but i have this error..
c = imread('lena.tif');
s = imread('boat.png');
[LL1,LH1,HL1,HH1]=dwt2(c,'db1');
[LL2,LH2,HL2,HH2]=dwt2(HH1,'db1');
n= size(LL2)
s = imresize(s,n);
for i=1:n
LL2(i,(n-6):end) = s(i,1:(i+4));
end
HH1_changed = idwt2(LL2,LH2,HL2,HH2,'db1');
c_changed = idwt2(LL1,LH1,HL1,HH1_changed,'db1');
imshow(mat2gray(c_changed))
error in " LL2(i,(n-6):end) = s(i,1:(i+4)); "

Akzeptierte Antwort

Nick
Nick am 8 Nov. 2018
Bearbeitet: Nick am 8 Nov. 2018
The error message is pretty much the answer, you are trying to assign 5 elements into 7 elements.
% Has 7 elements | Has 5 elements
LL2(i,(n-6):end) = s(i,1:(i+4));
assigning into 5 elements would mean you replace the index of your LL2
% correct assignment
LL2(i,(n-4):end) = s(i,1:5);
This is assuming you always want to use 5 If you assign using 1:(i+4), your vector size will increase each iteration:
because u are basically calling: 1:5, 1:6, etc. An other alternative is to have the first part transform along: i:(i+5). But i don't know the problem well enough to answer that
(edited - misread the 1:i+4 part)

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by