You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Check options and parameters of hypotenuse method](https://image-js.github.io/image-js-typescript/classes/Image.html#hypotenuse'github.io link')
2
+
3
+
:::caution
4
+
This method works only with images.
5
+
:::
6
+
7
+
A "hypotenuse filter" is using two compatible images to change values of each pixel by calculating [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance'wikipedia link on Euclidean distance') with the formula:
8
+
9
+
$$
10
+
NewValue = \sqrt{Value1^2+Value2^2}
11
+
$$
12
+
13
+
Where $$Value1$$ is a value of the pixel in the first image and $$Value2$$ is the value in the second one. The goal is to identify which points in one image correspond to points in another image, which is essential for various computer vision and image processing applications. Calculating hypotenuse value between two pixels is necessary for image aligning, feature matching.
14
+
15
+
:::caution
16
+
Images must be compatible by size, bit depth, number of channels and number of alpha channels. However, for the resulting image the bit depth and number of channels depends on the input options.
Copy file name to clipboardExpand all lines: docs/Features/Filters/level.md
+48-4Lines changed: 48 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,54 @@ import LevelDemo from './level.demo.tsx'
2
2
3
3
[Check options and parameters of level method](https://image-js.github.io/image-js-typescript/classes/Image.html#level'github.io link')
4
4
5
-
`level` method
6
-
Level method
7
-
enhances contrasts of the image
5
+
:::caution
6
+
This method only works with images.
7
+
:::
8
+
9
+
`level` method applies process called ["histogram equalization"](https://en.wikipedia.org/wiki/Histogram_equalization'wikipedia link on histogram equalization').
10
+
Histogram equalization is a technique used in image processing to enhance the contrast and visibility of details in an image by redistributing the pixel intensity values.
11
+
This process can make details in both dark and bright regions of the image more visible.
|[`channels`](https://image-js.github.io/image-js-typescript/interfaces/LevelOptions.html#channels)| no | - |
24
+
|[`gamma`](https://image-js.github.io/image-js-typescript/interfaces/LevelOptions.html#gamma)| no |`1`|
25
+
|[`inputMin`](https://image-js.github.io/image-js-typescript/interfaces/LevelOptions.html#inputMin)| no |`0`|
26
+
|[`inputMax`](https://image-js.github.io/image-js-typescript/interfaces/LevelOptions.html#inputMax)| no |`image.maxValue`|
27
+
|[`out`](https://image-js.github.io/image-js-typescript/interfaces/LevelOptions.html#out)| no | - |
28
+
|[`outputMin`](https://image-js.github.io/image-js-typescript/interfaces/LevelOptions.html#outputMin)| no |`0`|
29
+
|[`outputMax`](https://image-js.github.io/image-js-typescript/interfaces/LevelOptions.html#outputMax)| no |`image.maxValue`|
30
+
31
+
<details>
32
+
<summary><b>Implementation</b></summary>
33
+
34
+
Here's how level filter is implemented in ImageJS:
35
+
36
+
_Input border values selection_: The first step is to choose the range of values where the filter must be applied.
37
+
38
+
_Output border values selection_: Then the range of output values must be chosen. It is necessary to understand in what output limits should lie pixels that belong to the input values set.
39
+
40
+
_Calculation of the values_: After getting input and output values each pixel's gets compared with it and a ratio is calculated by using formula:
41
+
42
+
$$
43
+
(value - inputMin)/(inputMax - inputMin)
44
+
$$
45
+
46
+
where $$value$$ is a value of a pixel which is within the input borders. Otherwise it is equal to maximum input value.
47
+
From there the formula is reciprocated to compute new output value.
48
+
49
+
:::caution
50
+
`gamma` option allows choosing the curve by which points will be connected. It uses [Bezier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve'wikipedia link on bezier curves') to manipulate this shape. The bigger the value, the smoother the connection is.
51
+
:::
52
+
53
+
_Setting the values_: After calculating it, the filter replaces the original pixel value with this levelled value. This process is repeated for every pixel in the image, as the window moves over the entire image.
0 commit comments