Question: Problem A wireless sensor network consists of autonomous sensors scattered in a field where they monitor/detect/track objects and environmental conditions such as temperature, sound, and

Problem A wireless sensor network consists of autonomous sensors scattered in a field where they monitor/detect/track objects and environmental conditions such as temperature, sound, and pressure. In this lab, you are going to process information collected by sensor networks to detect possible objects and regions of interest.

Part I. Object Detection

A sensor network is deployed in a 2D field (a 2D rectangular grid) to detect objects of interest. For ease of data presentation, the collected sensor data isdescribed by anNNgrid of characters. The characters are in the rangeA...Z. The object could be an animal or a vehicle of some shape or color. Let the characters represent one of 26 possible colors. As the designer of the sensor network, you know roughly what you plan to detect. We define a potential object of interest (POI) as follows. A POI is a rectangular sub-grid (possibly the entire 2D grid) with sides parallel to the sides of the sensor network field which is a square. We stipulate that a POI must not be contained within any other POI. That is, no smaller subset of a POI is also a POI. Additionally, we expect a POI must contain exactly two colors. One of the two colors forms a contiguous region. The other color forms two or more contiguous regions. A real-world case would be to identify vehicles with camouflage. A region is considered to be contiguous if one can traverse the entire region by moving repeatedly from one cell in the region to another cell in the region taking steps up, down, left, or right (diagonals moves are not allowed).

For example, a 2D sensor field may produce sensor data as a rectangle with the following colors

CCCCC

CBCBC

CCCBB

This turns out to be a valid POI because the color C forms a single contiguous region and color B forms more than one contiguous region. In this dataset, we may have detected part of a vehicle.

In Part I, program to determine the number of potential objects of interest in the given 2D sensor data set.

INPUT FORMAT (file sensor1.txt):

The first line of input specifies the size of the sensor field N (where 1N20). The field is an NxN square. The nextNlines describe the data produced by the sensor network. Each line consists of N colors represented by N characters.

OUTPUT FORMAT (file sensor1out.txt):

Your solution must produce a single integer to indicate the number of potential objects of interest detected in the sensor field.

SAMPLE INPUT:

4

DBBZ

BBBZ

DDBB

DBBZ

SAMPLE OUTPUT:

2

In the example above, we can detect two potential objects of interest.

DBB

BBB

DDB

DBB

and

BZ

BZ

BB

BZ

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!