Image and Video Watermarking Algorithms using Optimization Techniques