Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Using Array data to read in Images

Subject: Using Array data to read in Images

From: Alexander

Date: 19 Apr, 2009 17:43:02

Message: 1 of 4

Hi,

I have an array in matalb called IMAGESDATA, each cell in the array holds two values; name and path, so for example "IMAGESDATA(1,1).name" = doneB.jpg and "IMAGESDATA(1,2).path" = C:\....... The array holds the details for 4 images.
I want to read in each of the images in seperatly using their path and name in the IMAGESDATA array.
so along the lines of:

     function Getimages(handles)
     global IMAGESDATA;
          
     A = (imread ( IMAGESDATA(1,2) + IMAGESDATA(1,1) ));
     B = (imread ( IMAGESDATA(2,2) + IMAGESDATA2,1) ));
     C = (imread ( IMAGESDATA(3,2) + IMAGESDATA(3,1) ));
     D = (imread ( IMAGESDATA(4,2) + IMAGESDATA(5,1) ));

Is there anyway of doing this?, do i need to put it in a function?, can anyone help?

Many Thanks

Alex

Subject: Using Array data to read in Images

From: Jiro Doke

Date: 19 Apr, 2009 18:37:01

Message: 2 of 4

"Alexander " <airkemp@gmail.com> wrote in message <gsfnr6$5e9$1@fred.mathworks.com>...
> Hi,
>
> I have an array in matalb called IMAGESDATA, each cell in the array holds two values; name and path, so for example "IMAGESDATA(1,1).name" = doneB.jpg and "IMAGESDATA(1,2).path" = C:\....... The array holds the details for 4 images.
> I want to read in each of the images in seperatly using their path and name in the IMAGESDATA array.
> so along the lines of:
>
> function Getimages(handles)
> global IMAGESDATA;
>
> A = (imread ( IMAGESDATA(1,2) + IMAGESDATA(1,1) ));
> B = (imread ( IMAGESDATA(2,2) + IMAGESDATA2,1) ));
> C = (imread ( IMAGESDATA(3,2) + IMAGESDATA(3,1) ));
> D = (imread ( IMAGESDATA(4,2) + IMAGESDATA(5,1) ));
>
> Is there anyway of doing this?, do i need to put it in a function?, can anyone help?
>
> Many Thanks
>
> Alex

Alex,

There are some inconsistencies in the way your described your problem. Do you have a cell array or an array of structures? "IMAGESDATA(1,1).name" is a syntax you use for structures. But then, I'm not sure why you don't have the path also stored in the (1,1) index, as in "IMAGESDATA(1,1).path".

So I'm just going to give you a general answer. If FILENAME contains the name of the file and PATHNAME contains the name of the path, you can create the full path to the file like this:

fullfile(PATHNAME, FILENAME)

Then pass that into IMREAD:

imread(fullfile(PATHNAME, FILENAME))


Hope this helps.

Subject: Using Array data to read in Images

From: Alexander

Date: 19 Apr, 2009 19:03:02

Message: 3 of 4

"Jiro Doke" <jiro.doke@mathworks.com> wrote in message <gsfr0d$qke$1@fred.mathworks.com>...
> "Alexander " <airkemp@gmail.com> wrote in message <gsfnr6$5e9$1@fred.mathworks.com>...
> > Hi,
> >
> > I have an array in matalb called IMAGESDATA, each cell in the array holds two values; name and path, so for example "IMAGESDATA(1,1).name" = doneB.jpg and "IMAGESDATA(1,2).path" = C:\....... The array holds the details for 4 images.
> > I want to read in each of the images in seperatly using their path and name in the IMAGESDATA array.
> > so along the lines of:
> >
> > function Getimages(handles)
> > global IMAGESDATA;
> >
> > A = (imread ( IMAGESDATA(1,2) + IMAGESDATA(1,1) ));
> > B = (imread ( IMAGESDATA(2,2) + IMAGESDATA2,1) ));
> > C = (imread ( IMAGESDATA(3,2) + IMAGESDATA(3,1) ));
> > D = (imread ( IMAGESDATA(4,2) + IMAGESDATA(5,1) ));
> >
> > Is there anyway of doing this?, do i need to put it in a function?, can anyone help?
> >
> > Many Thanks
> >
> > Alex
>
> Alex,
>
> There are some inconsistencies in the way your described your problem. Do you have a cell array or an array of structures? "IMAGESDATA(1,1).name" is a syntax you use for structures. But then, I'm not sure why you don't have the path also stored in the (1,1) index, as in "IMAGESDATA(1,1).path".
>
> So I'm just going to give you a general answer. If FILENAME contains the name of the file and PATHNAME contains the name of the path, you can create the full path to the file like this:
>
> fullfile(PATHNAME, FILENAME)
>
> Then pass that into IMREAD:
>
> imread(fullfile(PATHNAME, FILENAME))
>
>
> Hope this helps.

Hi Jiro, Thanks for getting back.

Applogies, IMAGESDATA is an array of structures, each structure within the array has 2 fields, path and name so IMAGESDATA(1,1) has a path field and a name field, IMAGESDATA(1,2) has a different path field and a name field so i need a way of access each individual field if possible.

any ideas?

Thanks

Alex

Subject: Using Array data to read in Images

From: Jiro Doke

Date: 19 Apr, 2009 19:13:01

Message: 4 of 4

"Alexander " <airkemp@gmail.com> wrote in message <gsfsh6$4lb$1@fred.mathworks.com>...
>
> Hi Jiro, Thanks for getting back.
>
> Applogies, IMAGESDATA is an array of structures, each structure within the array has 2 fields, path and name so IMAGESDATA(1,1) has a path field and a name field, IMAGESDATA(1,2) has a different path field and a name field so i need a way of access each individual field if possible.
>
> any ideas?
>
> Thanks
>
> Alex

Okay, so you should be able to do what I mentioned in the previous post:

imread(fullfile(IMAGESDATA(1,1).path, IMAGESDATA(1,1).name))

jiro

Tags for this Thread

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.

Contact us