フィルターのクリア

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 回表示 (過去 30 日間)
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)); "

採用された回答

Nick
Nick 2018 年 11 月 8 日
編集済み: Nick 2018 年 11 月 8 日
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)
  1 件のコメント
Maha Oueghlani
Maha Oueghlani 2018 年 11 月 8 日
Thank you for your reply.. in this exemple i will take the first 5 MSB so form 1 to 5 like what you mentionned

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by