フィルターのクリア

i'm working with image ,i cant load 512*512 image

1 回表示 (過去 30 日間)
Farjana Yeasmin
Farjana Yeasmin 2014 年 11 月 23 日
コメント済み: Farjana Yeasmin 2014 年 11 月 24 日
all time i face a error
Attempted to access N(1,1,3); index out of bounds because size(N)=[256,256,1].my code is here:
function [mg_length,mes] = embed_file(image_file1,text_file1)
clc
M=imread(image_file1); [X,Y,V] = size(M);
disp(sprintf('%d %d %d',X,Y,V));
%N=rgb2gray(M);
N=M;
T=N;
str={};
z='';
count=0;
fid = fopen(text_file1);
tline = fgetl(fid);
while ischar(tline)
if(length(tline)==0)
z=[z,char(dec2bin(13,8))];
z=[z,char(dec2bin(10,8))];
else
str=[str,tline];
t= dbinary(str);
if(count~=0)
z=[z,char(dec2bin(13,8))];
z=[z,char(dec2bin(10,8))];
end
z=[z,t];
end
count=count+1;
tline = fgetl(fid);
str='';
end
mes='';
disp(z); %disp(N);
imageSize=X*Y;
key=length(z);
mg_length=key;
disp('message length');
disp(key);
if(imageSize>key)
mes='embed successful';
d=1;
for i=1:X
for j=1:Y
a=N(i,j,3);
b=z(1,d);
[T(i,j,3),p]=changeImage2(a,b,key);
%a=N(i,j,2);
%[T(i,j,2),p]=changeImage2(a,b,length_Z);
%a=N(i,j,3);
%[T(i,j,3),p]=changeImage2(a,b,length_Z);
if(d==key)
break;
end
if(p==1)
d=d+1;
end
end
if(d==key)
break;
end
end
how can i fix it ?

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 11 月 23 日
Farjana - the error message is occurring because of the line of code
a=N(i,j,3);
which is trying to access the third dimension of the matrix N when it only has two dimensions (your input image is grayscale, 256x256, and not colour, 256x256x3). Either change the line of code to
a=N(i,j);
or select a colour image.
  4 件のコメント
Image Analyst
Image Analyst 2014 年 11 月 24 日
Farjana, the code was meant for color images. Since you have grayscale images, you commented out the color part but that's not all you need to do. You need to change the line of code that Geoff told you to. You probably also want to change T(i,j,3) to T(i,j).
Farjana Yeasmin
Farjana Yeasmin 2014 年 11 月 24 日
ok.. got a solution .. thank you

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by