Info
此问题已关闭。 请重新打开它进行编辑或回答。
hello every one, i'am a newbie, i have a error ? how can i fix it ???
1 次查看(过去 30 天)
显示 更早的评论
13 个评论
Walter Roberson
2020-6-8
Your posted code has reshape(w1,128,2) which would require that w1 had exactly 128*2 = 256 elements in it.
The error message is for reshape(w1,128,3) which would require that w1 had exactly 128*3 = 384 elements in it.
The 3 hints at RGB, but w1 is not RGB: it is the result of im2bw() and so is class logical.
Since it is black and white, 2 classes, that hints that the 2 in reshape(w1,128,2) might be referring to the number of expected classes, possibly.
Join Snow
2020-6-8
when I changed the input image file it reported the same error, but if the default is not the original error
Join Snow
2020-6-8
clc
clear all
close all
warning off
%% audio input
ok_classical=0; % 1 selected 0 not-selected 1 t?c là ch?n , 0 là không ch?n
ok_jazz=0;
ok_pop=0;
ok_looney=1;
if ok_classical
[y,Fs] = audioread('classical.wav');
end
if ok_jazz
[y,Fs] = audioread('jazz.wav');
end
if ok_pop
[y,Fs] = audioread('pop.wav');
end
if ok_looney
[y,Fs] = audioread('Song-Gio-Huong-Ly.wav');
end
x1=y(1:262144);
x1=reshape(x1,1,262144);
figure
plot(x1)
title('Host Audio')
xlabel(' Thoi gian (Mau)');
ylabel('Bien do');
x=reshape(x1,512,512);
Key=7;
[L1, L2]=size(x);
%% image input chuy?n ?nh màu v? ?nh xám
img = imread('unnamed.jpg'); %Get the input image, ?nh c?n ??a vào
I = rgb2gray(img);
po=im2bw(I);
w1=im2bw(I);%Convert to grayscale image chuy?n v? ?nh thang ?? xám
figure
imshow(w1)
%% cyclic code encoding// mã hóa theo chu kì
w1=reshape(w1,128,2);
n = 3; k = 2; % A (3,2) cyclic code
code1 = encode(double(w1),n,k,'cyclic/binary'); % 2 level of encoding
code2 = encode(code1(:,1:2),n,k,'cyclic/binary');
code3 = encode(code1(:,2:3),n,k,'cyclic/binary');
part1=reshape(code2(:,1:2),128,2);
part2=reshape(code2(:,2:3),128,2);
part3=reshape(code3(:,1:2),128,2);
part4=reshape(code3(:,2:3),128,2);
a1=horzcat(part1,part2);
b1=horzcat(part3,part4);
z=vertcat(a1,b1);
w1=reshape(z,32,32);
%% Arnold Scrambling with Key
w1=arnold(w1,Key);
%% 3 level of DWT decomposition with HAAR wavelet
[L,H,V,D]=dwt2(x,'haar','sym');
[CL,CH,CV,CD]=dwt2(H,'haar','sym');
[CA1,CA2,CA3,CA4]=dwt2(CH,'haar','sym');
for i=1:16
a(i)=4;
end
for i=1:16
b(i)=4;
end
%% DCT of sub-band block CH->CA2
newCA2=mat2cell(CA2,a,b);
d=zeros(64,64);
nCA2=mat2cell(d,a,b);
for i=1:16
for j=1:16
nCA2{i,j}=dct2(newCA2{i,j});
end
end
Walter Roberson
2020-6-8
We do not have your 'unnamed.jpg' file, so we do not know how big img is.
You need to run the code and tell us what size(w1) is when the code stops running.
Or you can attach unnamed.jpg or CW16.jpg for us to be able to find out ourselves what the size is.
Walter Roberson
2020-6-8
For the original CW16.jpg, then reshape(w1,128,2) works for me as w1 does have exactly 256 elements, as the img is 16 x 16.
However, unknown.jpg is 562 by 1679 and so has no chance of being reshaped to 128 x 2. If you were to try to resize it to 16 x 16 first, it would be unreadable.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)