Normal Flow from Brightness Constancy

~14 mincode completion

Implement normal_flow(Ix, Iy, It) returning the length-2 vector .

Examples

Pure Ix: It=-6, Ix=3 gives flow (2, 0)

Input
normal_flow(3, 0, -6)
Output
[2, 0]

Pure Iy: It=4, Iy=2 gives flow (0, -2)

Input
normal_flow(0, 2, 4)
Output
[0, -2]

A 45-degree gradient with It=-2 gives (1, 1)

Input
normal_flow(1, 1, -2)
Output
[1, 1]

Hints

Hint 1

Convert the input with before doing elementwise work.

Hint 2

Watch for this: dropped the minus sign on it.

Requirements

  • Return array of shape (2,): [u, v]

Constraints

  • Allowed library: NumPy only

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~14 min

8 employers weight this skill

4 autonomy companies, 1 defense company, 1 health and bio company, 1 enterprise vendor, 1 AI product company. Top match scores 93.

Python
import numpy as np


def normal_flow(Ix, Iy, It):
    """
    Minimum-length flow that satisfies brightness constancy.

    Args:
        Ix, Iy, It: scalars (spatial and temporal derivatives)

    Returns:
        array of shape (2,): [u, v]
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.