Skip to content

Commit 8ae4384

Browse files
EscapedGibbonstropitek
authored andcommitted
docs: add level and hypotenuse documentation
1 parent 9f28959 commit 8ae4384

File tree

4 files changed

+88
-6
lines changed

4 files changed

+88
-6
lines changed

docs/Features/Filters/hypotenuse.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[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.
17+
:::
18+
19+
### Parameters and default values
20+
21+
- `otherImage`
22+
23+
- `options`
24+
25+
#### Options
26+
27+
| Property | Required | Default value |
28+
| ------------------------------------------------------------------------------------------------------- | -------- | ---------------- |
29+
| [`bitDepth`](https://image-js.github.io/image-js-typescript/interfaces/HypotenuseOptions.html#bitDepth) | no | `image.bitDepth` |
30+
| [`channels`](https://image-js.github.io/image-js-typescript/interfaces/HypotenuseOptions.html#channels) | no | - |

docs/Features/Filters/level.demo.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { Image } from 'image-js';
22

33
export default function level(image: Image) {
4-
return image.level({ outputMin: 0, outputMax: 500, gamma: 1 });
4+
image = image.grey();
5+
return image.level({
6+
inputMin: image.maxValue - 200,
7+
inputMax: image.maxValue,
8+
outputMin: 0,
9+
outputMax: 300,
10+
gamma: 1,
11+
});
512
}

docs/Features/Filters/level.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,54 @@ import LevelDemo from './level.demo.tsx'
22

33
[Check options and parameters of level method](https://image-js.github.io/image-js-typescript/classes/Image.html#level 'github.io link')
44

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.
812

913
<LevelDemo />
1014

11-
how it works:
15+
### Parameters and default values
16+
17+
- `options`
18+
19+
#### Options
20+
21+
| Property | Required | Default value |
22+
| ---------------------------------------------------------------------------------------------------- | -------- | ---------------- |
23+
| [`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.
54+
55+
</details>

project-words.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ isodata
1616
renyi
1717
shanbhag
1818
thresholded
19-
RGBA
19+
RGBA
20+
bezier

0 commit comments

Comments
 (0)