1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anna35 [415]
3 years ago
12

Write a function, in the programming language of your choice, which finds contiguous regions (or "islands") in a matrix where al

l values in the island are greater than a threshold (but not necessarily the same). The function should take a threshold, a minimum island size, and an arbitrarily sized matrix as inputs. The function should output a matrix (same size as the input matrix) of booleans. Do not wrap around matrix edges. Corner neighbors are not sufficient for island continuity. For example, if the the inputs are: threshold = 5, min island size = 3, and matrix = [4, 4, 4, 2, 2; 4, 2, 2, 2, 2; 2, 2, 8, 7, 2; 2, 8, 8, 8, 2; 8, 2, 2, 2, 8]. Then the output would be [0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 0, 0, 1, 1, 0; 0, 1, 1, 1, 0; 0, 0, 0, 0, 0].
Engineering
1 answer:
ExtremeBDS [4]3 years ago
4 0

Answer:

#include <stdio.h>

int main()

{

int threshold = 5;

int i,j;

int matrix[5][5] = {{4, 4, 4, 2, 2},

{4, 2, 2, 2, 2},

{2, 2, 8, 7, 2},

{2, 8, 8, 8, 2},

{8, 2, 2, 2, 8}};

int row=(sizeof(matrix)/sizeof(matrix[0])); // length of row

int column=(sizeof(matrix)/sizeof(matrix[0][0]))/row; // length of column

printf("Input matrix value:\n");

for(i=0; i <5; i++)  

{

for(j=0; j<5; j++)

{

printf("%d ", matrix[i][j]);

}

printf("\n");

}

printf("\n");

for(i=0; i<column; i++)  

{

for(j=0; j<column; j++)

{

if ( (j == 0) || (j == column-1) ) // print 0 for first and last element of every row

printf("%d ", 0);

else

{

if(matrix[i][j] > threshold) // veify whether the element is more than threshold

{

printf("%d ",1);

}

else

{

printf("%d ", 0);

}

}

}

printf("\n");

}

return 0;

}

You might be interested in
From an aerial photograph, one observes that on a level section of a (multilane) highway, 25% of the vehicles are trucks, 75% ar
egoroff_w [7]

Answer:

(a) Flow rate of vehicles = No of vehicles per mile * Speed

=No of cars per mile * Speed +No of trucks per mile * Speed

= 0.75*50*60 + 0.25*50*40

=2750 vehicles / hour

(b) Let Density of vehicles on grade = x

Density on flat * Speed =Density on grade * Speed

So,( 0.75*50) * 60 + (0.25*50) * 40 = (0.75* x) * 55 + (0.25* x) * 25

So, x= 57.89

So, Density is around 58 Vehicles per Mile.

(c) Percentage of truck by aerial photo = 25%

(d)Percentage of truck bystationary observer on the grade= 25*30/60 * 25/55 =22.73 %

4 0
3 years ago
What is the Energy of moving things?<br><br> mechanical<br> sound<br> nuclear<br> Light
Elenna [48]

Answer: Kinetic energy

Explanation: If you live in a country other than UK you will probably call it something different

4 0
3 years ago
Read 2 more answers
Hằng số phổ biến chất khí
drek231 [11]

Answer:

Business activities may broadly be classified into two categories namely (A) Industry and (B) Commerce. Industry involves production of goods and services whereas commerce is concerned with the distribution of goods and services.

Explanation:

hope helps

7 0
3 years ago
Witch truck company is better.<br><br> Ram <br> Ford <br> Toyoda<br> GMC
arlik [135]
Ram is the better truck company
7 0
3 years ago
Read 2 more answers
What does Clay say will happen if the system is rejected?
juin [17]

Answer:

the nation will suffer terrible consequences

Explanation:

I did that and got it right

6 0
3 years ago
Read 2 more answers
Other questions:
  • A BS of 5.43 ft is taken on a level rod at a 120-ft distance, and a FS of 8.76 ft is taken on the rod held 1,100 feet away.(a) W
    6·1 answer
  • .The war of the currents in the 1880's involved Thomas Edison and Nikola Tesla on a reality TV show stranded on an island. Each
    9·1 answer
  • A parallel circuit with two branches and an 18 volt battery. Resistor #1 on the first branch has a value of 220 ohms and resisto
    7·1 answer
  • Chemical materials that are transported are called..
    8·1 answer
  • Ten dollars per hour is about how much income per year
    5·2 answers
  • You are working as an electrical technician. One day, out in the field, you need an inductor but cannot find one. Looking in you
    11·1 answer
  • In addition to passing an ASE certification test, automotive technicians must have __________ year(s) of on the job training or
    15·1 answer
  • Metal and dirt are not considered contaminants to oll.<br> A) O True<br> B) O False
    13·2 answers
  • In what ways did electrical switches have to change to progress from the
    13·1 answer
  • 6. During some actual expansion and compression processes in piston–cylinder devices, the gases have been
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!