displaying images on axes in MATLAB

조회 수: 22 (최근 30일)
Chethan
Chethan 2013년 4월 27일
댓글: Image Analyst 2016년 3월 1일
I have a GUI with 5 axes in it, where images which are stored in text file(notepad) are displayed. Images in text file are not static, it keeps updating with new ones. I mean for first search images are different and after closing all windows again if i run same program for next search different images may get saved in notepad.
function displayResults(filename, header)
figure('Position',[200 100 700 400], 'MenuBar', 'none', 'Name', header, 'Resize', 'off', 'NumberTitle', 'off');
% Open 'filename' file... for reading...
fid = fopen(filename);
for N=1:5
imagename = fgetl(fid);
if ~ischar(imagename), break, end % Meaning: End of File...
(x) = imread(imagename);
axes(handles.axesN);
imshow(fname);
xlabel(imagename);
end
fclose(fid);
filename is text file
I need to fit these images on all 5 axes, but I'm getting error like undefined variable handles.axesN How can i go for it?
  댓글 수: 1
Jan
Jan 2013년 4월 29일
The question is not clear to me. You have posted the code 3 times now, but this does not increase the chance to understand it.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2013년 4월 27일
편집: Jan 2013년 4월 27일
What do you expect "handles.axesN" to be? perhaps you want:
axes(handles.(sprintf('axes%d', N)));
  댓글 수: 7
Babatunde Otaru
Babatunde Otaru 2016년 3월 1일
편집: Babatunde Otaru 2016년 3월 1일
Hi Guys, any update on this? I am having this same error. My code snippet below:
axes(handles.axesTagName);
imshow(theImage)
Image Analyst
Image Analyst 2016년 3월 1일
For his function displayResults(), handles was not passed in to the function so the function cannot see it. You'd need to pass in handles via the input argument list in order to use it inside the function.
handles is not a global variable that is automatically seen by all functions in the m-file, so if you want to use it, you must pass it in.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2013년 4월 28일
There are only 5, so get rid of the loop and just do it explicitly
% Read in image 1
theImage = imread(filename);
axes(handles.axes1);
imshow(theImage);
% Read in image 2
theImage = imread(filename);
axes(handles.axes2);
imshow(theImage);
and so on.
I suggest you use fullfile(), and exist(filename, 'file') to construct the full filename (folder + base filename + extension) and check to see that it actually exists.
  댓글 수: 1
Chethan
Chethan 2013년 4월 29일
편집: Chethan 2013년 4월 29일
Let me explain you, this is my calling function FIG5 GUI M-file
disp('Texture results saved...');
displayResults('textureResults.txt', 'Texture Results...');
guidata(hObject,handles)
and displayResults is another separate function.
function displayResults(filename, header)
figure('Position',[200 100 700 400], 'MenuBar', 'none', 'Name', header, 'Resize', 'off', 'NumberTitle', 'off');
% Open 'filename' file... for reading...
fid = fopen(filename);
for N=1:5
imagename = fgetl(fid);
if ~ischar(imagename), break, end % Meaning: End of File...
(x) = imread(imagename);
axes(handles.axesN);
imshow(fname);
xlabel(imagename);
end
fclose(fid);
Now this will open separate window to display those images( with subimages and all, I've edited), but I've 5 axes in FIG5 GUI where exactly i need to display these images. FOR loop is must because I've 15 images in another similar GUI. Do i need to remove figure('position', [200 100. . .) line in above code?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by