How do I read an image from a different folder into my .m file using Matlab in Ubuntu?

3 ビュー (過去 30 日間)
Deepa Nair
Deepa Nair 2015 年 4 月 24 日
回答済み: sruthi N 2017 年 12 月 13 日
I am able to access images from a folder using Matlab in Windows. I use Matlab 2010a with Ubuntu 14.04. How do I read an image from a folder which is outside the current folder into my .m file?

回答 (4 件)

Sreeram Mohan
Sreeram Mohan 2015 年 4 月 24 日
Hi Deepa,
Did you try adding the folder that your image exists into path and try out ?
You could programatically add the folder to the MATLAB path as well using
>> addpath(folderName);
hope this helps !!
Thanks,
Sreeram Mohan
  2 件のコメント
Deepa Nair
Deepa Nair 2015 年 4 月 24 日
Thank you Sreeram. I tried with addpath also. This is the code I tried..
InputImg= dir(fullfile('home\Deepa\Documents\reading_DB\images\*.jpg')); InputDir ='home\nit\Documents\After_compre\reading_DB\images\';
InputN = {InputImg.name};
for Imagenum = 1:length(InputImg) filename = InputImg(Imagenum); name = strcat(InputDir,filename);
In_img = imread(filename);
figure()
imshow(In_img,[]);
title('Input Image');
end
In the work space, it still shows inputN as a 0x0 cell.
Deepa Nair
Deepa Nair 2015 年 4 月 24 日
A correction: both path in the program are the same InputImg= dir(fullfile('home\Deepa\Documents\reading_DB\images\*.jpg')); InputDir ='home\Deepa\Document\reading_DB\images\';

サインインしてコメントする。


Michael Haderlein
Michael Haderlein 2015 年 4 月 24 日
Possibly the file separator you use is wrong? In Unix systems you use "/" while in Windows you use "\". However, you write "dir(fullfile('home\Deepa\Documents\reading_DB\images\*.jpg'))", so I guess you have chosen the wrong one. You can use filesep to get the correct separator.

Sreeram Mohan
Sreeram Mohan 2015 年 4 月 28 日
Hi Deepa,
First off could you please first reduce the problem to a simple one so that we can see what is the real issue ?
1) Could you please copy 1 jpg file into the present working directory wherever the script is being run and then verify without path if imread and the imshow work ? 2) Next once that is working could you please try putting the image in a location that is smaller in length and try ? may be less than 64 characters ? If even this work then proceed to 3rd step 3) Try using a longer path name and see if that works !
Hope this will give a better insight into where the issue is popping in from ?
--sreeram

sruthi N
sruthi N 2017 年 12 月 13 日
In image processing i have real time image. but its read only the specific software like that Radiant Dicom viewer, so how will i read the image from this software in m.file

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by