From: Aydos R on
hi there,
I have a strange error...When I check the folder "s_te 8.jpg" exists in the "c_te_s" folder but it gives an error while program running...does any1 can help me,please?

??? Error using ==> imread at 372
File "s_te 8.jpg" does not exist.

Error in ==> msr_hough at 6
c3=imread(a3(i3).name);

Error in ==> mushR_main at 38
[datahough,datamax,dataind]= msr_hough('./datas/data_cr/data_cr_c/c_te_s/*.jpg');

main program :
--------------------
..
msr_crop('./datas/data_cr/data_cr_b/c_te_b/*.jpg',3);
[datahough,datamax,dataind]= msr_hough('./datas/data_cr/data_cr_c/c_te_s/*.jpg');
..

msr_crop :
--------------
function msr_crop(filenm2,choice1)
a2=dir(filenm2);
[num3 num4]=size(a2);
for i2=1:num3;
c2=imread(a2(i2).name);
crp = imcrop(c2);
if choice1==1;
imwrite(crp, sprintf('./datas/data_cr/data_cr_c/c_ed_s/s_ed %d.jpg', i2));
else if choice1==2;
imwrite(crp, sprintf('./datas/data_cr/data_cr_c/c_po_s/s_po %d.jpg', i2));
else if choice1==3;
imwrite(crp, sprintf('./datas/data_cr/data_cr_c/c_te_s/s_te %d.jpg', i2));
end
end
end
end
close figure 1

msr_hough :
-----------------
function [datahough,datamax,dataind]=msr_hough(filenm3)
a3=dir(filenm3);
[num5 num6]=size(a3);
for i3=1:num5;
c3=imread(a3(i3).name);
cx=rgb2gray(c3);
S = edge(cx,'canny');
[H, theta,rho]=hough(S);
for cnt = 1:max(max(H))
data(cnt) = sum(sum(H == cnt));
end
[maxval,maxind] = max(data);
medval = median(data);
[ccsz1 ccsz2]=size(data);
for k3=1:ccsz2;
datahough(i3,k3)=data(1,k3);
end
datamax(i3,:)=maxval;
dataind(i3,:)=maxind;
end

NOTE : num3=num5=8;
From: Walter Roberson on
Aydos R wrote:

> I have a strange error...When I check the folder "s_te 8.jpg" exists in
> the "c_te_s" folder but it gives an error while program running...does
> any1 can help me,please?
>
> ??? Error using ==> imread at 372
> File "s_te 8.jpg" does not exist.

> msr_crop('./datas/data_cr/data_cr_b/c_te_b/*.jpg',3);

> msr_crop : --------------
> function msr_crop(filenm2,choice1)
> a2=dir(filenm2);

dir() applied to a relative path is legal and will return the desired information

> [num3 num4]=size(a2);
> for i2=1:num3;
> c2=imread(a2(i2).name);

However, the .name field of the structure so returned will only have the basic
name, and will _not_ have the directory name as part of it. You then try to
read the file with the basic name but you are not in that other directory so
it fails.

Consider using fileparts() to break up filenm2 into directory and basic name
('*.jpg') and using fullfilename() to construct the complete file name from
the directory and .name field.
From: us on
"Aydos R" <buralardabiri(a)hotmail.com> wrote in message <i3cp88$6np$1(a)fred.mathworks.com>...
> hi there,
> I have a strange error...When I check the folder "s_te 8.jpg" exists in the "c_te_s" folder but it gives an error while program running...does any1 can help me,please?
>
> ??? Error using ==> imread at 372
> File "s_te 8.jpg" does not exist.
>
> Error in ==> msr_hough at 6
> c3=imread(a3(i3).name);

well... if your A3(I3).NAME is the output of a call to DIR, the .NAME field ONLY contains the file name and NOT the absolut/relative path...

us
From: Aydos R on
thank you for replying...I will try your solution recommendations...

but the thing is ... first 7 jpg files can be read properly...just the last image gives error...I thought it is about timing...I tried to pause 3secs and wait for the crop function for writing image...then "msr_hough" function will have time to "dir" directory including 8 images...but it did not work...still I have the problem...when I check it step by step in debug mode...the 8th image can also be read...it is still a strange problem for me...
From: us on
"Aydos R" <buralardabiri(a)hotmail.com> wrote in message <i3csbk$isv$1(a)fred.mathworks.com>...
> thank you for replying...I will try your solution recommendations...
>
> but the thing is ... first 7 jpg files can be read properly...just the last image gives error...I thought it is about timing...I tried to pause 3secs and wait for the crop function for writing image...then "msr_hough" function will have time to "dir" directory including 8 images...but it did not work...still I have the problem...when I check it step by step in debug mode...the 8th image can also be read...it is still a strange problem for me...

ok... but this is not related to the error message you've shown in your OP...
unless, the missing file is created by your program - and - is not yet put into your folder's directory structure, which may happen if you don't work on local disks, for instance...

try this before the offending line

if exist(yourfilename,'file')
% continue
else
disp(sprintf('cannot access file %s',yourfilename));
keyboard;
% now inspect your folder
end

us