hm, what i'm thinking of does not work 100%, but no other idea comes to my mind.
Define 5 different variables as empty array
Now go through all your layers, apply the average filter on each and with the color sampler get the r, g and b values.
If the values do not exist in neither of those 5 variables, save them as one of the variables and save the image (e.g. by copying the layer to another document)
Should work in estimated 95% of the cases ;-)
Make just the two layers visible. Set the blend mode on the top layer to Difference. Then try this:
app.activeDocument.histogram.slice(1).toString().replace(/,0/g, "") == "0"
This will evaluate to true if the layers are identical and false if there are any differences.
X, that is how I would check using the UI as a visual check, I think it could work… but wouldn't this only work in the instance of them being on top of each other? ( pixel for pixel ) I read this that a forest may be a couple of tress as such but my guess is they are placed at random locations… or did I just overlook some of your clever trickery/voodoo…?
but wouldn't this only work in the instance of them being on top of each other?
That bit of code presumes:
- The layers are in the same document
- The layers are the only two layers visible
- The content of the layers is aligned.
- The layers have simple content (no layer masks, vector masks, layer styles)
There may be other assumptions that I'm making, but this is all that I can think of.
For the trees/forest problem, I would iterate though the tree-layers.
Create a new document that is as large as the largest tree-layer in the forest.
Hide the background layer.
Copy the first layer to the new document.
Copy the second layer to the new doc
Do the layer comparison code from above my previous post
If the layers are the same, delete the new one.
Go to the next layer in the forest document.
Copy and compare the new layer against each layer in the new document.
Delete it if it's a dupe.
When you're done, the new document should have only the unique trees.
Ah… no Voodoo then this time… I was thinking a similar thing only… I think I would have probably aligned all layers in the document centrally ( except b/g ) then worked down the stack… removing untill uniques are left… I couldn't think of another method other than 'difference' to check thou…
Thanks for the great suggestions. I'll give them a shot over the weekend and let you know how it goes.