Link to home
Start Free TrialLog in
Avatar of SSupreme
SSupremeFlag for Belarus

asked on

Quiz thinking

The image analysis
Recently in scientific research institute of computing biology there was an uneasy problem. This problem consists in the analysis of the images received by means of electronic microscopes.
Before carrying out of the analysis of the image pass some stages of a filtration. At the first stage the image is translated in monochrome, i.e. having only two colour: white and black. The second stage is more difficult and consists at a distance noise from the image by filter selection. But it has appeared uneasy as for different kinds of images different filters are necessary. For the purpose of selection of the suitable filter it has been decided to carry out before the second stage of a filtration additional calculations.
Additional calculations consist in a finding of factor of connectivity of the initial image. The connectivity factor is a number of various pairs the next pixels.
The image represents the rectangular table of pixels of the size NxM. Each pixel has either white colour, or black. Two various pixels are called as next if following conditions are satisfied:
1. Both pixels have white colour.
2. Both pixels are either in the same column or in the same line.
3. All pixels which are either in line, or in a column between the specified pixels, are white.
 User generated imageDrawing No1: N = 5 and M = 6, an example of the next symbols for pixel (2, 4).
For resulted above an example all painted over pixels are next for the pixel designated by an asterisk. Two pairs the next pixels which can be received one of another by means of shift of elements, are not considered as the various. That is pair of the next pixels {(2; 4), (2; 6)} and pair {(2; 6), (2; 4)} are not considered as the various.
As it was entrusted to you to write to the younger scientific employee of scientific research institute the program which under the set description of the image counts factor of connectivity of the given image.

Entrance data
The first line of an entrance file contains two integers N and M (1 = N, M = 200).
Further follow N lines on M symbols in everyone, describing the initial monochrome image. A symbol ‘. ’ (ASCII 46) – designates a white symbol, and ‘ # ’ (ASCII 35) – black.
Target data
A single whole number – factor of connectivity of the initial monochrome image.

Q: How to solve it using programming language?
Avatar of SSupreme
Flag of Belarus image


Well, I didn't study it and I have solutions. The question is about communication between calculator and human. I need to know how to solve it, what would be logical structure or steps to complete the quiz, and I don't need the solution.
Avatar of TommySzalapski
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I would do it in C++ since that's what I know. If you post the code you have so far, I can help you get it working.
Also, the instruction is not clear. Is the factor of connectivity the sum of all the connected portions or the maximum? Is there one for both rows and columns or are they combined into one?
Here is solution: solution.cpp
if your input is:
3 4
Could you please explain answer for the input?
Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great job. Thanks for reviews.