In this post, we'll dynamic Programming with OpenCV : Implementing Kadane’s Algorithm to find brightest area on Astronomical images and videos.

We all have come across various OpenCV libraries and have been using them to get the brightest area’s or spot’s on images. Apparently, we have our cv2.minMaxLoc(…) in OpenCV to do this and get our location. But have you ever wondered could we employ an dynamic programming method for this approach.

This is a problem that's called the maximum contiguous subarray sum in Algorithms. We usually have a 1d array and are asked to find the maximum sum that's possible out of all subarrays of that array. We can employ brute force method to solve it in O(n²) times or a divide and conquer to get it in O(log n) times. We will use dynamic programming for our approach to get it in O(n) times.

Coming to our problem, we have an image which we can read using an OpenCV method and we process the image to get a 2D array out of it.

data-structures python opencv dynamic-programming kadanes-algorithm

Python Programming & Data Handling

I will focus on some of the most common problems or should I say, encounters, and their solutions using data structures and algorithms of standard python modules. So let’s dive into the world of “Python+” which is all about adding something more into what we know of Python.

This is an introduction to dynamic array and its implementation. An array is a contiguous area of memory of equal-size elements.

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

Data Structures in Python explains what exactly makes it efficient to implement Data Structures and Algorithms with an example.