-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclose.ts
39 lines (28 loc) · 877 Bytes
/
close.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import Bitmap from './bitmap.ts';
import StructuralElement from './structural.ts';
import dilate from './dilate.ts';
import erode from './erode.ts';
/**
* Funkcja wykonuje zamknięcie elementem linijnym o
* parametrach pobranych od użytkownika
* @param bitmap Obraz wejściowy
* @returns Obraz po zamknięciu
*/
const close = (bitmap: Bitmap) => {
let input = prompt("Podaj długość");
if(!input)
throw new Error("Nie podano długości");
const length = Number(input);
input = prompt("Podaj kąt nachylenia (deg)");
if(!input)
throw new Error("Nie podano kąta");
const angle = Number(input);
const se = StructuralElement.line(length, angle);
console.log(" ");
se.print();
console.log(" ");
let result = dilate(bitmap, se);
result = erode(result, se);
return result;
}
export default close;