I'm trying to assign random image files that undergo rescaling to a list of variable names. The images I'm trying to assign are the result of mapping the ImageResize function of two arguments to the Randomly generated images, where the 2nd argument has a fixed value. However when I assign the values to a list of variables, the Scaled[50]
argument is not being applied to the images. Thanks.
I store 15 random images in variables tmp[1]
, tmp[2]
, ... using a Do statment and recall them using another statement:
Do[tmp[i] = Image[RandomReal[1, {8, 12, 3}]], {i, Range[1, 15]}];
tmp /@ Range[1, 15]
(See Assigning values to a list of variable names)
Now I want to Scale all the images 50x and store them in a list of variables. It can overwrite the tmp variables, but for simplicity I'll use new variables:
Do[var[j] = ImageResize[#, Scaled[50]] & /@ tmp[j], {j, Range[1, 15]}];
(See Mapping a function of two arguments where the 2nd arg has a fixed value)
When I recall them using
var /@ Range[1,15]
they are not scaled, it is the same images as in tmp /@ Range[1,15]
unscaled.
This code produces the desired result on a single image
var[1]=ImageResize[tmp[1], Scaled[50]]
so I'm not sure why the second Do statment does not produce the desired list of rescaled images. If there is a way to do it in the initial creation of the images (in the first Do statement) that is better.
Do
asDo[var[j] = ImageResize[tmp[j], Scaled[50]], {j, Range[1, 15]}];
or, better, use @belisarius suggestion. Also,var=Table[ImageResize[j, Scaled[50]], {j, tmp /@ Range[1, 15]}]
. $\endgroup$