Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-106

Largest Connected Component Area

Problem

Find the area of the largest 4-connected component of 1-valued pixels in a binary mask.

Return 0 when there are no 1 pixels.

Test cases

case 1
in: [[[1,1,0],[0,1,0],[1,0,0]]]
expected: 3
case 2
in: [[[1,0],[0,1]]]
expected: 1
case 3
in: [[[0,0],[0,0]]]
expected: 0
case 4
in: [[[1,1,1],[1,1,1]]]
expected: 6
Starter codePython
def largest_component_area(mask):
    # Your code here
    pass

4 test cases · run your code against them in the editor