Skip to content

Commit

Permalink
refactor lab1
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym Shylo committed Jun 9, 2024
1 parent b4cdec5 commit 4afa766
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 171 deletions.
Binary file added .imgs/lab1/test1/decoded_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .imgs/lab1/test1/input_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .imgs/lab1/test1/noised_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .imgs/lab1/test2/decoded_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .imgs/lab1/test2/input_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .imgs/lab1/test2/noised_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2020] [Maksym Shylo and Ruslan Khomenko]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
74 changes: 63 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,68 @@
# Statistical Methods of Pattern Recognition
Labs for University Course
Laboratory work from the university course.

## Lab 1 - Generate string of letters from noised input image
#### Examples
## Setup

To run these applications you need to have **Python3.10**.

1. Clone repo:
```bash
git clone https://github.com/maksymshylo/computational_geometry.git
```
2. Create virtual environment.
```bash
python3.10 -m venv .venv
```
3. Activate it
```bash
python3 generate_string.py input_string noise_level
source .venv/bin/activate
```
4. Install requirements:
```bash
pip install -r requirements.txt
```

cd lab1/
## Lab 1 - Recognition of a noised image.

python3 generate_string.py 'some noised string' 0.2
python3 generate_string.py 'hello world' 0.35
### Description
> The program converts a string to noised image and then decodes it.
### Usage
```commandline
$ python3 lab1/decode_string.py --help
usage: decode_string.py [-h] --input_string INPUT_STRING --noise_level NOISE_LEVEL [--seed SEED]
options:
-h, --help show this help message and exit
--input_string INPUT_STRING
input string
--noise_level NOISE_LEVEL
noise level of bernoulli distribution
--seed SEED seed to debug
```
## Lab 2 - Recognizing Black Vertical and Horizontal Lines

### Examples
```bash
python3 lab1/generate_string.py --input_string "billy herrington" --noise_level 0.35 --seed 45
```
Decoded string: "billy herrington"

| Original image | Noised image | Decoded image |
|---------------------------------------|:--------------------------------:|-----------------------------------|
| ![](.imgs/lab1/test1/input_image.png) | ![](.imgs/lab1/test1/noised_image.png) | ![](.imgs/lab1/test1/decoded_image.png) |

```bash
python3 lab1/generate_string.py --input_string "billy herrington" --noise_level 0.45 --seed 45
```
Decoded string: "nde deauff sc"

| Original image | Noised image | Decoded image |
|---------------------------------------|:--------------------------------------:|-----------------------------------------|
| ![](.imgs/lab1/test2/input_image.png) | ![](.imgs/lab1/test2/noised_image.png) | ![](.imgs/lab1/test2/decoded_image.png) |


## Lab 2 - Recognition of black vertical and horizontal lines using Gibbs Sampling
#### Examples
##### `Gibbs Sampler Solution`

```bash
python3 lab2/gibbs_sampler_grid.py height_of_image width_of_image number_of_generated_lines noise_level column_probability number_of_iterations
Expand All @@ -29,12 +78,15 @@ python3 lab2/gibbs_sampler_grid.py height_of_image width_of_image number_of_gene
python3 lab2/precise_solution.py 20 20 5 0.3 0.5
python3 lab2/precise_solution.py 10 10 3 0.2 0.5
```
## Lab 3 - Gibbs Sampler for recognizing string over another one with noise

## Lab 3 - Gibbs Sampler for recognizing a noised string over another one

> Note: Lengths of string should be the same.
#### Examples
```bash
python3 row_over_row.py input_string_1 input_string_2 noise_level number_of_iterations

cd lab3/

python3 row_over_row.py 'row' 'owr' 0.2 10
python3 row_over_row.py 'swap' 'paws' 0.33 30
Expand Down
Loading

0 comments on commit 4afa766

Please sign in to comment.