Dynamic Programming with OpenCV : Implementing Kadane’s Algorithm

Dynamic Programming with OpenCV : Implementing Kadane’s Algorithm

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Python Programming & Data Handling

Python Programming & Data Handling

Python+ 101: Most useful data structures and algorithms

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.

Data Structure and Algorithms — Implement Dynamic Array in Python

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

Basic Data Types in Python | Python Web Development For Beginners

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 | Data Structures and Algorithms in Python

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