Image pattern generation with context

@moaz mujahid