Info
This question is closed. Reopen it to edit or answer.
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
hello every one, i'am a newbie, i have a error ? how can i fix it ???
1 view (last 30 days)
Show older comments
13 Comments
Walter Roberson
on 8 Jun 2020
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
on 8 Jun 2020
when I changed the input image file it reported the same error, but if the default is not the original error
Join Snow
on 8 Jun 2020
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
on 8 Jun 2020
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
on 8 Jun 2020
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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)