Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!news.glorb.com!postnews.google.com!r3g2000vbp.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Guide, load image from folder
Date: Mon, 18 May 2009 04:23:44 -0700 (PDT)
Organization: http://groups.google.com
Lines: 53
Message-ID: <45c06a8d-1591-4c4c-a67e-f8a516ff9c95@r3g2000vbp.googlegroups.com>
References: <ggq8t2$mcg$1@fred.mathworks.com> <ggqa9i$679$1@fred.mathworks.com> 
	<ggqg52$7jo$1@fred.mathworks.com> <ggs8ev$539$1@fred.mathworks.com> 
	<ggt06r$nfm$1@fred.mathworks.com> <guqoa5$d6p$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.70.56
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1242645824 24909 127.0.0.1 (18 May 2009 11:23:44 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 18 May 2009 11:23:44 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: r3g2000vbp.googlegroups.com; posting-host=75.186.70.56; 
	posting-account=0rLUzAkAAABojYSRC64DkTbtiSCX77HH
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; 
	GTB6; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 
	3.5.21022),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:540677


On May 18, 12:31 am, "ridhi jain" <rivi_j...@yahoo.co.in> wrote:
> "Image Analyst" <imageanal...@mailinator.com> wrote in message <ggt06r$nf=
...@fred.mathworks.com>...
> > "Rui Gomes" <rpgome...@gmail.com> wrote in message <ggs8ev$53...@fred.m=
athworks.com>...
> > ----------------------------------------
> > Rui:
> > I'm not sure why you chose to not use my code and go with something les=
s robust.  You should have used my code.  The problem with your code is=
 that if the user selects a file that is not in the current working directo=
ry, your code will throw an error.  This is because you're totally ignori=
ng the folder, which can get returned as an optional return argument from u=
igetfile().  You need to use fullfile as I had shown you.  Checking for=
 the user clicking the cancel button is a good idea though.  Here is some=
 robust code that will work for any jpg image (the format you seem to want)=
 located in any folder, and also checks for the user clicking the Cancel bu=
tton:
>
> > clc;
> > [BaseFileName,PathName,FilterIndex] = uigetfile('*.jpg');
> > if(BaseFileName ~= 0)
> >    fullFileName = fullfile(PathName, BaseFileName);
> >    inputImageArray = imread(fullFileName);
> >    image(inputImageArray);
> >    axis off;
> > end
>
> > I suggest you use the above code instead of your code - it will be more=
 robust.  I also suggest you use descriptive variable names.  Many MATL=
AB users also recommend against the use of i as a variable since it indicat=
es a comples number, but since MATLAB is case sensitive, capital I will be =
okay, just not that descriptive, especially if you plan on having other ima=
ge variables in your program.
> > Regards,
> > ImageAnalyst
>
> hi,
> the code you suggested above worked really very well for colored images. =
But when it came to grayscale images the image that appeared on the axes wa=
s red in color. Why is it so? How can this code be modified to get the corr=
ect image in the axes?- Hide quoted text -
>
> - Show quoted text -

---------------------------------------------------------------------------=
---------------
ridhi:
First check to make sure that you really have a 2D monochrome image
and not a 3D color image.  If it is indeed monochrome, then you must
have a colormap applied.  Use colormap('gray') to set the colormap to
grayscale.
Regards,
ImageAnalyst