code: def num_adjacent(self, i, j):
          
          # check values
          if i < 1 or i > self.height - 2 or j < 1 and j > self.width - 2:
              raise ValueError('Pixels out of bounds')
  
          # count the number of blacks
          count = 0
          diffs = [[-1, 0], [1, 0], [0, -1], [0, 1]]
          for d in diffs:
              if self.data[i + d[0]][j + d[1]] > self._threshold:
                  count += 1
          return count
docs: Counts the number of adjacent nonzero pixels to a given pixel.
  
          Parameters
          ----------
          i : int
              row index of query pixel
          j : int
              col index of query pixel
  
          Returns
          -------
          int
              number of adjacent nonzero pixels