Clear Filters
Clear Filters

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 view (last 30 days)
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)); "

Accepted Answer

Nick
Nick on 8 Nov 2018
Edited: Nick on 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)

More Answers (0)

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!