Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Farjana Yeasmin
Farjana Yeasmin el 23 de Nov. de 2014
Comentada: Farjana Yeasmin el 24 de Nov. de 2014
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 ?

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 23 de Nov. de 2014
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 comentarios
Image Analyst
Image Analyst el 24 de Nov. de 2014
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 el 24 de Nov. de 2014
ok.. got a solution .. thank you

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by