We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I would like to use a series of image masks, in which each would consist of a randomly placed ellipse. I’ve provided three examples of masks that would belong to the larger set of masks I would like to generate. I don’t want to have to draw out thousands of masks, generating each permutation by hand. Is there a way to do this without pre-creating each mask?
Mask 1
Mask 2
Mask 3
Etc...
Answers
yes, you can use a for loop i 0 to 100 or so and place a ellipse randomly and save it
tested
here the name is like name1.jpg, name2.jpg etc.
[edited]
Yep, and use a PGraphic to mask an image:
This question is an extension of the above question. I am trying to expand on the code mentioned above to do the following: Pulling from a data set of multiple images (let's say 6 images in this case, though it will be thousands in the final piece), draw a randomly placed ellipse from image 1, then draw a randomly placed ellipse from image 2, and so on. The below code appears to be close but I can't figure out what I'm doing wrong. (I've embedded the test images below in case they are useful.)
Here what I came up with. Using a PGraphics to persist drawings avoiding a huge number of PGraphics. Is this that you want?
Yes, what you've done is the end product that I need, but I need to be able to load thousands of images without writing them out as below:
My files will be named as follows: "pic1.jpg", "pic2.jpg", "pic3.jpg", up to maybe "pic9476.jpg".
I'm quite new to arrays. What's be best way for me to load them?
like @chrisir said above...
do it in setup().
check out this great tutorial: http://wiki.processing.org/w/From_several_variables_to_arrays
Thanks _vk. It looks like I'm mostly there but I can't figure out how to invoke (correct word?) the array in the draw method.
This line is currently a problem:
And I'm guessing that this one will be also:
I looked at the link you gave me and have tried to impliment it but I think I'm missing something key.
This is what I currently have:
I've tried to invoke the 'n'th number using a new method at the bottom of the code.
You are mixing things up a bit... I believe the error you get in line
imgA[index].mask(mask);
is "ArrayIndexOutOfBounds: 6" right? That's because the array has only 6 places, not 16... I made some changes and comments in your code: untested...Updated the code assigning images to array slots... I haven't noticed that.
Your explanation of everything has been very clear--thank you so much. I have a much better understanding of what is going on now, and how each part of the code is working.
I have two last questions for you: 1) The images I've been using are test images and are smaller (640 x 360). At some point between using 800 x 450px images (which work) and 1200 x 675 images (which don't) the program doesn't work. I don't get any error messages, just a grey display window where nothing happens. The images I want to use will likely range from 1920 x 1080, up to something like 4000 x 3000. Do you know what's causing this?
2) I've been looking for ways to change the alpha of the dots, but from what I've seen it's not possible with PGraphics masks. Is that right?
Translucent masks are possible:
http://bazaar.launchpad.net/~philho/+junk/Processing/view/head:/_QuickExperiments/MaskImage/MaskImage.pde
Just draw the mask with gray, not with alpha.
Great; thanks PhiLho! That answers the seciond question perfectly. I just need to figure out the first question then--why I can't get the image data set to contain larger images (like 1920 x 1080 or 4000 x 3000).
Memory?
I don't think so. I was using a data set of 4 images.
Maybe something related to the fact that mask() expects an image of the same dimensions as the one to be masked? Try narrow down the issue...
does images display fine without any mask ?
Is your handling of size (are you resizing? positioning bigger images?) working fine alone?
can you mask each image alone?
and things like that...
I'm wondering if I can load the images one at a time before drawing each one (instead of pre-loading them all in the setup).
Can this:
Happen one at a time in the draw method?
loading images is slow, if you load them during draw, the sketch will hang until it is loaded. Usually is recommended to load them at setup(). That said you can use a global var incremented in draw to build your file name, and then I think you don't need the array, like:
UNTESTED
We're gonna need to know how many pictures you're gonna need and their expected dimensions.
Also how many you're gonna need to display at a given time.
Whether it's always forward, or do you need to get back to previous 1s. Are they numbered as well???
Java offers a huge selection of structures to store objects.
And choosing the right 1 w/ the right strategy (like using threads), anything can be overcome! >:/
Ok, thanks guys. I won't have time to test this for at least a few days, but when I do, I'll let you know how it works!
To answer your question GoToLoop, the program is intended to handle a variety of data sets, each with varying numbers and dimensions. Having said that, I can say that likely dimensions will include: 1) 3000x4000px 2) 1920x1080px
In terms of the number of images in each data set... this can range from high hundreds to several thousands or in some cases tens of thousands.
Although it would be ideal to be able to play the program in realtime in the Processing viewer, I can also write in some export code (either as a still sequence or as a video) and handle output of the final work that way. In that case, loading images slowly wouldn't be a problem.
You gave more details, but at the same time haven't answered all of my requests. Like for example how many images per screen.
Seems like you got a group of images bound to some particular data set, is it so?
Since a complete image loading involves reading from disk + decompressing + convert to internal format, it is indeed very slow!
What I have in mind is for you implementing a separate Thread to deal in creating a pool of pre-loaded images.
That'd involve some amount of loadImage() in advance and discard old 1s.
But the key here is anticipation of which images to pre-load among them.
Hence the main part of your program gotta request to that separate part
a bunch of images early on, so it's ready available to be displayed w/o any loading delay.