<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097</link>
    <title>MATLAB Central Newsreader - Guide, load image from folder</title>
    <description>Feed for thread: Guide, load image from folder</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 29 Nov 2008 02:20:18 -0500</pubDate>
      <title>Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#613804</link>
      <author>Rui Gomes</author>
      <description>Hi, i need to load several images, and is the user who will select the image.&lt;br&gt;
&lt;br&gt;
what i want to do is, with a button open a menu to the user chose the image, and then the program will display the image, that will be process (in the future :P).&lt;br&gt;
&lt;br&gt;
thanks for the help.</description>
    </item>
    <item>
      <pubDate>Sat, 29 Nov 2008 02:44:02 -0500</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#613807</link>
      <author>Rui Gomes</author>
      <description>&quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggq8t2$mcg$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi, i need to load several images, and is the user who will select the image.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; what i want to do is, with a button open a menu to the user chose the image, and then the program will display the image, that will be process (in the future :P).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks for the help.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
that is what i found to the moment in the guide i program a calback of a button&lt;br&gt;
&lt;br&gt;
function button_open_Callback(hObject, eventdata, handles)&lt;br&gt;
&lt;br&gt;
%%load image&lt;br&gt;
image_loaded=UIIMPORT('-file');&lt;br&gt;
&lt;br&gt;
axes(handles.axes2);&lt;br&gt;
image(image_loaded); &lt;br&gt;
axis off;&lt;br&gt;
&lt;br&gt;
guidata(hObject, handles);&lt;br&gt;
&lt;br&gt;
this code do not work because where:&lt;br&gt;
&lt;br&gt;
image(image_loaded); &lt;br&gt;
&lt;br&gt;
is expecting this image(image_loaded.filename);&lt;br&gt;
&lt;br&gt;
there is any way to get this filename ??&lt;br&gt;
&lt;br&gt;
&amp;nbsp;thanks for the help.</description>
    </item>
    <item>
      <pubDate>Sat, 29 Nov 2008 04:18:02 -0500</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#613819</link>
      <author>Image Analyst</author>
      <description>&quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggqa9i$679$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggq8t2$mcg$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi, i need to load several images, and is the user who will select the image.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; what i want to do is, with a button open a menu to the user chose the image, and then the program will display the image, that will be process (in the future :P).&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; thanks for the help.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; that is what i found to the moment in the guide i program a calback of a button&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function button_open_Callback(hObject, eventdata, handles)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; %%load image&lt;br&gt;
&amp;gt; image_loaded=UIIMPORT('-file');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; axes(handles.axes2);&lt;br&gt;
&amp;gt; image(image_loaded); &lt;br&gt;
&amp;gt; axis off;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; guidata(hObject, handles);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; this code do not work because where:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; image(image_loaded); &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; is expecting this image(image_loaded.filename);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; there is any way to get this filename ??&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  thanks for the help.&lt;br&gt;
-------------------------------------------------------------------------------------&lt;br&gt;
Try this:&lt;br&gt;
&lt;br&gt;
clc;&lt;br&gt;
[FileName,PathName,FilterIndex] = uigetfile('*.*');&lt;br&gt;
fullFileName = fullfile(PathName, FileName);&lt;br&gt;
inputImageArray = imread(fullFileName);&lt;br&gt;
image(inputImageArray); &lt;br&gt;
axis off; &lt;br&gt;
&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Sat, 29 Nov 2008 04:24:02 -0500</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#613820</link>
      <author>Ryan Ollos</author>
      <description>&quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggqa9i$679$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; function button_open_Callback(hObject, eventdata, handles)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; %%load image&lt;br&gt;
&amp;gt; image_loaded=UIIMPORT('-file');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; axes(handles.axes2);&lt;br&gt;
&amp;gt; image(image_loaded); &lt;br&gt;
&amp;gt; axis off;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; guidata(hObject, handles);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; this code do not work because where:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; image(image_loaded); &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; is expecting this image(image_loaded.filename);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; there is any way to get this filename ??&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  thanks for the help.&lt;br&gt;
&lt;br&gt;
Try:&lt;br&gt;
&lt;br&gt;
fileName = uigetfile;&lt;br&gt;
I = imread(fileName);&lt;br&gt;
set(handle.axes, 'CData', I);</description>
    </item>
    <item>
      <pubDate>Sat, 29 Nov 2008 20:25:03 -0500</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#613898</link>
      <author>Rui Gomes</author>
      <description>&quot;Ryan Ollos&quot; &amp;lt;ryano@physiosonics.com&amp;gt; wrote in message &amp;lt;ggqg52$7jo$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggqa9i$679$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; function button_open_Callback(hObject, eventdata, handles)&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; %%load image&lt;br&gt;
&amp;gt; &amp;gt; image_loaded=UIIMPORT('-file');&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; axes(handles.axes2);&lt;br&gt;
&amp;gt; &amp;gt; image(image_loaded); &lt;br&gt;
&amp;gt; &amp;gt; axis off;&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; guidata(hObject, handles);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; this code do not work because where:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; image(image_loaded); &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; is expecting this image(image_loaded.filename);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; there is any way to get this filename ??&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;  thanks for the help.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Try:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fileName = uigetfile;&lt;br&gt;
&amp;gt; I = imread(fileName);&lt;br&gt;
&amp;gt; set(handle.axes, 'CData', I);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
thanks to both, you solve my problem&lt;br&gt;
&lt;br&gt;
here the solution i use &lt;br&gt;
&lt;br&gt;
fileName = uigetfile('*.jpg');&lt;br&gt;
if(fileName ~= 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I = imread(fileName);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;image(I)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;axis off;&lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 03:10:19 -0500</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#613937</link>
      <author>Image Analyst</author>
      <description>&quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggs8ev$539$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
----------------------------------------&lt;br&gt;
Rui:&lt;br&gt;
I'm not sure why you chose to not use my code and go with something less 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 directory, your code will throw an error.  This is because you're totally ignoring the folder, which can get returned as an optional return argument from uigetfile().  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 button:&lt;br&gt;
&lt;br&gt;
clc;&lt;br&gt;
[BaseFileName,PathName,FilterIndex] = uigetfile('*.jpg');&lt;br&gt;
if(BaseFileName ~= 0) &lt;br&gt;
	fullFileName = fullfile(PathName, BaseFileName);&lt;br&gt;
	inputImageArray = imread(fullFileName);&lt;br&gt;
	image(inputImageArray); &lt;br&gt;
	axis off; &lt;br&gt;
end &lt;br&gt;
&lt;br&gt;
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 MATLAB users also recommend against the use of i as a variable since it indicates 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 image variables in your program.&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Mon, 18 May 2009 04:31:01 -0400</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#650544</link>
      <author>ridhi jain</author>
      <description>&quot;Image Analyst&quot; &amp;lt;imageanalyst@mailinator.com&amp;gt; wrote in message &amp;lt;ggt06r$nfm$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggs8ev$539$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; ----------------------------------------&lt;br&gt;
&amp;gt; Rui:&lt;br&gt;
&amp;gt; I'm not sure why you chose to not use my code and go with something less 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 directory, your code will throw an error.  This is because you're totally ignoring the folder, which can get returned as an optional return argument from uigetfile().  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 button:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; clc;&lt;br&gt;
&amp;gt; [BaseFileName,PathName,FilterIndex] = uigetfile('*.jpg');&lt;br&gt;
&amp;gt; if(BaseFileName ~= 0) &lt;br&gt;
&amp;gt; 	fullFileName = fullfile(PathName, BaseFileName);&lt;br&gt;
&amp;gt; 	inputImageArray = imread(fullFileName);&lt;br&gt;
&amp;gt; 	image(inputImageArray); &lt;br&gt;
&amp;gt; 	axis off; &lt;br&gt;
&amp;gt; end &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 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 MATLAB users also recommend against the use of i as a variable since it indicates 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 image variables in your program.&lt;br&gt;
&amp;gt; Regards,&lt;br&gt;
&amp;gt; ImageAnalyst&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
hi,&lt;br&gt;
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 was red in color. Why is it so? How can this code be modified to get the correct image in the axes?</description>
    </item>
    <item>
      <pubDate>Mon, 18 May 2009 11:23:44 -0400</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#650601</link>
      <author>ImageAnalyst</author>
      <description>On May 18, 12:31&#160;am, &quot;ridhi jain&quot; &amp;lt;rivi_j...@yahoo.co.in&amp;gt; wrote:&lt;br&gt;
&amp;gt; &quot;Image Analyst&quot; &amp;lt;imageanal...@mailinator.com&amp;gt; wrote in message &amp;lt;ggt06r$nf=&lt;br&gt;
...@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Rui Gomes&quot; &amp;lt;rpgome...@gmail.com&amp;gt; wrote in message &amp;lt;ggs8ev$53...@fred.m=&lt;br&gt;
athworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; ----------------------------------------&lt;br&gt;
&amp;gt; &amp;gt; Rui:&lt;br&gt;
&amp;gt; &amp;gt; I'm not sure why you chose to not use my code and go with something les=&lt;br&gt;
s robust. &#160;You should have used my code. &#160;The problem with your code is=&lt;br&gt;
&amp;nbsp;that if the user selects a file that is not in the current working directo=&lt;br&gt;
ry, your code will throw an error. &#160;This is because you're totally ignori=&lt;br&gt;
ng the folder, which can get returned as an optional return argument from u=&lt;br&gt;
igetfile(). &#160;You need to use fullfile as I had shown you. &#160;Checking for=&lt;br&gt;
&amp;nbsp;the user clicking the cancel button is a good idea though. &#160;Here is some=&lt;br&gt;
&amp;nbsp;robust code that will work for any jpg image (the format you seem to want)=&lt;br&gt;
&amp;nbsp;located in any folder, and also checks for the user clicking the Cancel bu=&lt;br&gt;
tton:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; clc;&lt;br&gt;
&amp;gt; &amp;gt; [BaseFileName,PathName,FilterIndex] = uigetfile('*.jpg');&lt;br&gt;
&amp;gt; &amp;gt; if(BaseFileName ~= 0)&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160;fullFileName = fullfile(PathName, BaseFileName);&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160;inputImageArray = imread(fullFileName);&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160;image(inputImageArray);&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160;axis off;&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I suggest you use the above code instead of your code - it will be more=&lt;br&gt;
&amp;nbsp;robust. &#160;I also suggest you use descriptive variable names. &#160;Many MATL=&lt;br&gt;
AB users also recommend against the use of i as a variable since it indicat=&lt;br&gt;
es a comples number, but since MATLAB is case sensitive, capital I will be =&lt;br&gt;
okay, just not that descriptive, especially if you plan on having other ima=&lt;br&gt;
ge variables in your program.&lt;br&gt;
&amp;gt; &amp;gt; Regards,&lt;br&gt;
&amp;gt; &amp;gt; ImageAnalyst&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; hi,&lt;br&gt;
&amp;gt; the code you suggested above worked really very well for colored images. =&lt;br&gt;
But when it came to grayscale images the image that appeared on the axes wa=&lt;br&gt;
s red in color. Why is it so? How can this code be modified to get the corr=&lt;br&gt;
ect image in the axes?- Hide quoted text -&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; - Show quoted text -&lt;br&gt;
&lt;br&gt;
---------------------------------------------------------------------------=&lt;br&gt;
---------------&lt;br&gt;
ridhi:&lt;br&gt;
First check to make sure that you really have a 2D monochrome image&lt;br&gt;
and not a 3D color image.  If it is indeed monochrome, then you must&lt;br&gt;
have a colormap applied.  Use colormap('gray') to set the colormap to&lt;br&gt;
grayscale.&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Mon, 18 May 2009 14:13:01 -0400</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#650646</link>
      <author>ridhi jain</author>
      <description>Thanx for the reply.&lt;br&gt;
I observed that in case of jpeg images the grayscale image was correctly displayed but the same was not true for bmp images.&lt;br&gt;
ridhi</description>
    </item>
    <item>
      <pubDate>Mon, 18 May 2009 17:46:02 -0400</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#650710</link>
      <author>ridhi jain</author>
      <description>hi,&lt;br&gt;
once again i am encountering the problem of displaying a grayscale image on axes.&lt;br&gt;
In my project when i watermark an image i immediately want to display the watermarked image in the axes. I used the simple code:&lt;br&gt;
f = fullfile('C:','Users','ongc','Documents','MATLAB','watermark112.jpg')&lt;br&gt;
t = imread(f);&lt;br&gt;
axes(handles.axes9);&lt;br&gt;
image(t);&lt;br&gt;
axis off ;&lt;br&gt;
&lt;br&gt;
when i insert this code just after my code for watermarking the image, i go errors such as:&lt;br&gt;
Error in ==&amp;gt; final&amp;gt;insert_watermark_stego_Callback at 224&lt;br&gt;
axes(handles.axes7);&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; gui_mainfcn at 96&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;feval(varargin{:});&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; final at 42&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gui_mainfcn(gui_State, varargin{:});&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt;&lt;br&gt;
guidemfile&amp;gt;@(hObject,eventdata)final('insert_watermark_stego_Callback',hObject,eventdata,guidata(hObject))&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
??? Error while evaluating uicontrol Callback&lt;br&gt;
&lt;br&gt;
Then i trie to use another push button to display the image in the axes. The image was displayed but was red in color as the previous case. Image as u said is 2D monochrome. What is the solution to this.&lt;br&gt;
Thanx for your help...&lt;br&gt;
&lt;br&gt;
-ridhi</description>
    </item>
    <item>
      <pubDate>Mon, 18 May 2009 23:34:02 -0400</pubDate>
      <title>Re: Guide, load image from folder</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240097#650779</link>
      <author>Ryan Ollos</author>
      <description>The error messages issued when an errors are encountered in a callback are very difficult trace to the actual problem.  You really just need to set a breakpoint and where the error occurs, and inspect the variables.</description>
    </item>
  </channel>
</rss>

