Count blobs in a 2D matrix - PrismoSkills
Count blobs in a 2D matrix Problem: Given a 2D matrix of booleans where true indicates white and false indicates black. Considering group of adjacent black cells to be one blob, find the number of blobs in the matrix. Example: Consider the below 6x5 matrix: 0 1 2 3 4 0 The solution function should output a count of 3 in the above case. Solution: Code: // Pseudo code in java int findBlobCount (int matrix[][], int rowCount, int colCount) { int visited[][] = new int[rowCount][colCount]; // all initialized to false int count=0; for (int i=0; iRead full article from Count blobs in a 2D matrix - PrismoSkills