Got Questions? Get Answers.
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:
images

Subject: images

From: Jessica

Date: 6 Jun, 2008 02:49:02

Message: 1 of 5

Hi,

I have a list of images, such as:

a='C:\Sample\a.bmp';
b='C:\Sample\b.bmp';
c='C:\Sample\c.bmp';
...

I would like to create a loop in which I can display these
images in a randomized order without replacement
(displaying each image for 5 sec before displaying the next
image). For example one iteration of the loop would produce:

imshow(a)%5 sec pause
imshow(b)%5 sec pause
imshow(c)%5 sec pause

while another may produce:

imshow(b)%5 sec pause
imshow(a)%5 sec pause
imshow(c)%5 sec pause

Does anyone have any suggestions?

Thanks!

Subject: images

From: anu tika

Date: 6 Jun, 2008 03:30:06

Message: 2 of 5


 "I would like to create a loop in which I can display these
 images in a randomized order without replacement"

Hi Jessica,
           You should see this site:
http://en.wikipedia.org/wiki/Linear_feedback_shift_register/
I think this will help u to produce random numbers by using
the same logic in your code. If say u have 3 images u can
use LFSR to produce random numbers (also provide a check for
collision) for each image and then arrange them in ascending
or descending order.

i hope my advice is of some help

good luck
 

Subject: images

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 6 Jun, 2008 04:12:02

Message: 3 of 5

In article <g2a8it$imf$1@fred.mathworks.com>,
Jessica <jyorzinski@ucdavis.edu> wrote:

>I have a list of images, such as:

>I would like to create a loop in which I can display these
>images in a randomized order without replacement

randperm()
--
  "MAMA: Oh--So now it's life. Money is life. Once upon a time freedom
   used to be life--now it's money. I guess the world really do change.
   WALTER: No--it was always money, Mama. We just didn't know about it."
                                              -- Lorraine Hansberry

Subject: images

From: ImageAnalyst

Date: 6 Jun, 2008 11:31:03

Message: 4 of 5

On Jun 6, 12:12=A0am, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <g2a8it$im...@fred.mathworks.com>,
>
> Jessica =A0<jyorzin...@ucdavis.edu> wrote:
> >I have a list of images, such as:
> >I would like to create a loop in which I can display these
> >images in a randomized order without replacement
>
> randperm()
> --
> =A0 "MAMA: Oh--So now it's life. Money is life. Once upon a time freedom
> =A0 =A0used to be life--now it's money. I guess the world really do change=
.
> =A0 =A0WALTER: No--it was always money, Mama. We just didn't know about it=
."
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 -- Lorraine Hansberry

------------------------------------
Jessica:
Like Walter said, you can use randperm. Then you just need to figure
out which array to display. You could stick the images into a higher
order array and then just get them out of that using the randperm
value as an index. For example, load all the 2D monochrome images
into one big 3D array, or all the 3D color images into one big 4
dimensional array. This is good if you have a lot of memory - enough
to read in ALL of the images you intend to display. This also works
if you have a variable number of images, like if people selected some
variable number of filenames from a listbox. The other option would
be to put the randperm value into a big switch/case statement and read
it in from disk each time. This takes less memory but could be slower
because of having to do disk access each time. The same method would
also work if you just kept a bunch of separate images as variables in
memory. This method works only for a known number of images because
you have to put in a case statement for each one.
Regards,
ImageAnalsyt
-----------------------------------------------------

Subject: images

From: Jessica

Date: 6 Jun, 2008 13:36:03

Message: 5 of 5

ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<764de644-a7f3-4bbe-b830-
7b392401ef3d@f63g2000hsf.googlegroups.com>...
> On Jun 6, 12:12=A0am, rober...@ibd.nrc-cnrc.gc.ca (Walter
Roberson)
> wrote:
> > In article <g2a8it$im...@fred.mathworks.com>,
> >
> > Jessica =A0<jyorzin...@ucdavis.edu> wrote:
> > >I have a list of images, such as:
> > >I would like to create a loop in which I can display
these
> > >images in a randomized order without replacement
> >
> > randperm()
> > --
> > =A0 "MAMA: Oh--So now it's life. Money is life. Once
upon a time freedom
> > =A0 =A0used to be life--now it's money. I guess the
world really do change=
> .
> > =A0 =A0WALTER: No--it was always money, Mama. We just
didn't know about it=
> ."
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=A0 =A0 =A0 =A0 =
> =A0 =A0 =A0 =A0 =A0 -- Lorraine Hansberry
>
> ------------------------------------
> Jessica:
> Like Walter said, you can use randperm. Then you just
need to figure
> out which array to display. You could stick the images
into a higher
> order array and then just get them out of that using the
randperm
> value as an index. For example, load all the 2D
monochrome images
> into one big 3D array, or all the 3D color images into
one big 4
> dimensional array. This is good if you have a lot of
memory - enough
> to read in ALL of the images you intend to display. This
also works
> if you have a variable number of images, like if people
selected some
> variable number of filenames from a listbox. The other
option would
> be to put the randperm value into a big switch/case
statement and read
> it in from disk each time. This takes less memory but
could be slower
> because of having to do disk access each time. The same
method would
> also work if you just kept a bunch of separate images as
variables in
> memory. This method works only for a known number of
images because
> you have to put in a case statement for each one.
> Regards,
> ImageAnalsyt
> -----------------------------------------------------

Thanks for these suggestions. Based on what was advised, I
came up with:

x = str2mat
('C:\Users\Desktop\Sample\a.bmp','C:\Users\Desktop\Sample\b.
bmp','C:\Users\Desktop\Sample\c.bmp');
NumberofPictures=3;
RandomNumber=randperm(3);
imread('C:\Users\Desktop\Sample\a.bmp');
imread('C:\Users\Desktop\Sample\b.bmp');
imread('C:\Users\Desktop\Sample\c.bmp');

for S=1:NumberofPictures
    T=RandomNumber(1,S);
    ImageUp =x(T,:);
    imshow(ImageUp);
    end;

I am much closer to what I need to do but still am
uncertain about some things. Is there something that I can
write to indicate how long each picture will remain on the
screen? Is there a way to make it so the picture fills up
the entire screen without saying "Figure 1," "File," etc.
(i.e., so the loop is like a slideshow presentation)?

Tags for this Thread

No tags are associated with 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