Thanks Jase00 and alextro for your response.
I'm still not able to get the desired output. In my case multiple layers are involved as shown in the attached image.
In every frame there's a background image and then there are foreground item images. Also there's another top layer which is having frame structure with black color.
Now at any point in time, images from 1 frame should not come on top of images from other frames.
Kindly share your thoughts on this.