Thread Subject: how to read from curernt directory

Subject: how to read from curernt directory

From: Talal Khan

Date: 29 Jan, 2008 14:38:01

Message: 1 of 5

hey.

I basically make an executable standalone file and i CAN
use it on other computers. the only problem is the PATH i
have set for a picture to be read.

 path1='C:\Documents and Settings\Talal Khan\My
Documents\MATLAB\TTT.jpeg';

 path2='C:\Documents and Settings\Talal Khan\My
Documents\MATLAB\wall.JPEG';

%%later they are converted to grayscale images.

 SRC1=loadGrayScaleImage(path1);
 SRC2=loadGrayScaleImage(path2);


Obviously other pc's will not have these paths in their
computers. i want to read the file TTT.jpeg and wall.JPEG
from the directory i copy the standalone program, not from
the directories already set in path1 and path2.

how can i do that?

how can it read these files from the current directory on
the computer,and not having to set a fixed path?

Subject: how to read from curernt directory

From: David

Date: 29 Jan, 2008 15:01:03

Message: 2 of 5

"Talal Khan" <talaltk@mathwork.com> wrote in message
<fnndo9$gcu$1@fred.mathworks.com>...
> hey.
>
> I basically make an executable standalone file and i CAN
> use it on other computers. the only problem is the PATH
i
> have set for a picture to be read.
>
> path1='C:\Documents and Settings\Talal Khan\My
> Documents\MATLAB\TTT.jpeg';
>
> path2='C:\Documents and Settings\Talal Khan\My
> Documents\MATLAB\wall.JPEG';
>
> %%later they are converted to grayscale images.
>
> SRC1=loadGrayScaleImage(path1);
> SRC2=loadGrayScaleImage(path2);
>
>
> Obviously other pc's will not have these paths in their
> computers. i want to read the file TTT.jpeg and
wall.JPEG
> from the directory i copy the standalone program, not
from
> the directories already set in path1 and path2.
>
> how can i do that?
>
> how can it read these files from the current directory
on
> the computer,and not having to set a fixed path?


path1='TTT.jpeg';
path2='wall.JPEG';

Subject: how to read from curernt directory

From: Talal Khan

Date: 29 Jan, 2008 15:27:01

Message: 3 of 5

i know thats what i thought i wud do but when i do this it
still gives me an error... something like this i dono what
cud it be....

Error using ==> imread at 315
File "Call11.jpeg" does not exist.

Error in ==> loadGrayScaleImage at 25
MYIMAGE=imread(path);

Error in ==> talaltest2>pushbutton5_Callback at 976
SRC2=loadGrayScaleImage(path2);


"David " <dave@bigcompany.com> wrote in message
<fnnf3e$85s$1@fred.mathworks.com>...
> "Talal Khan" <talaltk@mathwork.com> wrote in message
> <fnndo9$gcu$1@fred.mathworks.com>...
> > hey.
> >
> > I basically make an executable standalone file and i
CAN
> > use it on other computers. the only problem is the
PATH
> i
> > have set for a picture to be read.
> >
> > path1='C:\Documents and Settings\Talal Khan\My
> > Documents\MATLAB\TTT.jpeg';
> >
> > path2='C:\Documents and Settings\Talal Khan\My
> > Documents\MATLAB\wall.JPEG';
> >
> > %%later they are converted to grayscale images.
> >
> > SRC1=loadGrayScaleImage(path1);
> > SRC2=loadGrayScaleImage(path2);
> >
> >
> > Obviously other pc's will not have these paths in
their
> > computers. i want to read the file TTT.jpeg and
> wall.JPEG
> > from the directory i copy the standalone program, not
> from
> > the directories already set in path1 and path2.
> >
> > how can i do that?
> >
> > how can it read these files from the current directory
> on
> > the computer,and not having to set a fixed path?
>
>
> path1='TTT.jpeg';
> path2='wall.JPEG';
>

Subject: how to read from curernt directory

From: Ian Clarkson

Date: 29 Jan, 2008 15:44:04

Message: 4 of 5

"Talal Khan" <talaltk@mathwork.com> wrote in message
<fnngk5$3sk$1@fred.mathworks.com>...
> i know thats what i thought i wud do but when i do this
it
> still gives me an error... something like this i dono
what
> cud it be....
>
> Error using ==> imread at 315
> File "Call11.jpeg" does not exist.
>
> Error in ==> loadGrayScaleImage at 25
> MYIMAGE=imread(path);
>
> Error in ==> talaltest2>pushbutton5_Callback at 976
> SRC2=loadGrayScaleImage(path2);
>
>
> "David " <dave@bigcompany.com> wrote in message
> <fnnf3e$85s$1@fred.mathworks.com>...
> > "Talal Khan" <talaltk@mathwork.com> wrote in message
> > <fnndo9$gcu$1@fred.mathworks.com>...
> > > hey.
> > >
> > > I basically make an executable standalone file and i
> CAN
> > > use it on other computers. the only problem is the
> PATH
> > i
> > > have set for a picture to be read.
> > >
> > > path1='C:\Documents and Settings\Talal Khan\My
> > > Documents\MATLAB\TTT.jpeg';
> > >
> > > path2='C:\Documents and Settings\Talal Khan\My
> > > Documents\MATLAB\wall.JPEG';
> > >
> > > %%later they are converted to grayscale images.
> > >
> > > SRC1=loadGrayScaleImage(path1);
> > > SRC2=loadGrayScaleImage(path2);
> > >
> > >
> > > Obviously other pc's will not have these paths in
> their
> > > computers. i want to read the file TTT.jpeg and
> > wall.JPEG
> > > from the directory i copy the standalone program, not
> > from
> > > the directories already set in path1 and path2.
> > >
> > > how can i do that?
> > >
> > > how can it read these files from the current
directory
> > on
> > > the computer,and not having to set a fixed path?
> >
> >
> > path1='TTT.jpeg';
> > path2='wall.JPEG';
> >
>

make sure the file is in the same folder as the .m file
you're running... you could try putting a 'dir' command in
there just to get a file listing to make sure you're not
going crazy.

Subject: how to read from curernt directory

From: Talal Khan

Date: 29 Jan, 2008 16:59:02

Message: 5 of 5

yeah they in the same directory...i think it has to do
somethin with the loadGrayScaleImage.m.....



this is wahts in the loadGrayScaleImage.m

----------------------------------------------------------





function [MYIMAGE] = loadGrayScaleImage(path)
%the FUNCTION loadGrayScaleImage accepts a string (path)
and loads the image found in that path. In the case that
% the image is a color image , it is converted to gray
scale image. THe foramt of the imag is adjusted so that it
is
% compatible with the function in the image processing
MATLAB toolbox (i.e the range of intnsities is in the
% range of 0-1.
%
% inputs:
% path - The path for loading the image
%
% outputs:
% MYIMAGE, the image loaded
%
%



% replace the first letter of the full path with the first
letter of the current pathg
% this will make sure that we het the correctsave path
eventhough the drive letter on
% a different machine is difefrent
currentpath=pwd;
path(1)=currentpath(1);


% load the image
MYIMAGE=imread(path);


% in the case that the image is color image, convert it to
gray scale image
if (isrgb(MYIMAGE)==1)
    MYIMAGE = rgb2gray(MYIMAGE);
end


%arrange the image intensities so that they are in the
range of 0-1, since MATLAB requies the image intensities
%to be in that range in order to be able to use MATLAB
image processing functions
if(isa(MYIMAGE,'uint8') == 1)
   MYIMAGE = double(MYIMAGE) / 256;
else
   MYIMAGE = double(MYIMAGE);
end
if ( ((max(max(max(MYIMAGE)))) > 1) | ((min(min(min
(MYIMAGE)))) < 0) )
   error('All images used in Machine Vision toolbox must
contain pixels on the interval [0,1]');
end








----------------------------------------------------------

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
path Talal Khan 29 Jan, 2008 09:40:12
current directory Talal Khan 29 Jan, 2008 09:40:12
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com