Skip to content

Commit 4a9feb2

Browse files
docs: add getting started section and more (#70)
1 parent 3b41111 commit 4a9feb2

25 files changed

+433
-28
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
.vscode
1919
frontmatter.json
2020

21+
.vscode
22+
.frontmatter
23+
frontmatter.json
24+
2125
npm-debug.log*
2226
yarn-debug.log*
2327
yarn-error.log*

docs/Basics/Basics.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import DocCardList from '@theme/DocCardList';
2+
3+
<DocCardList />

docs/Basics/Working with Images.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import ImageDemo from './image.demo.tsx'
2+
3+
<!-- TODO add analysis section once it is merged -->
4+
5+
### What is an Image?
6+
7+
In the context of digital technology and computing, images are represented as a grid of pixels, with each pixel containing information about color and intensity.
8+
9+
### Types of images supported by ImagesJS
10+
11+
- Currently ImageJS supports images with these characteristics:
12+
13+
| | TIFF | JPEG | PNG |
14+
| -------------------------------- | -------------------------- | ---------------------- | ----------------- |
15+
| **Bits per channel** | 8 or 16 bits | 8 bits | 8 or 16 bits |
16+
| **Bits per Alpha** | 8 or 16 bits | N/A | 8 or 16 bits |
17+
| **Compression** | yes/no(may be destructive) | no(may be destructive) | yes |
18+
| **Color Model** | RGB and grayscale | RGB and grayscale | RGB and grayscale |
19+
| **Can be loaded in this format** | &#9989; | &#9989; | &#9989; |
20+
| **Can be saved in this format** | &#10060; | &#9989; | &#9989; |
21+
22+
### Properties
23+
24+
In ImageJS main properties of an image are:
25+
26+
- width
27+
28+
- height
29+
30+
- data: typed array with information about image's pixels.
31+
32+
- [Color model](../Glossary.md#color-model 'internal link on glossary'): the abstract model of how pixel colors are formed.
33+
34+
- [Bit depth](../Glossary.md#bit-depth 'internal link on glossary'): number of bits allocated to each channel.
35+
36+
- [Number of channels/components](../Glossary.md#channel 'internal link on glossary'): number of color channels that each pixel has. Grey image has one, RGB-type of image has three.
37+
38+
- [Metadata](../Glossary.md#metadata 'internal link on metadata'): data about data.
39+
40+
The latter ones matter most in features that involve two images, like [hypotenuse method](../Features/Comparison/Hypotenuse.md 'internal link on hypotenuse') or [subtraction method](../Features/Comparison/Subtraction.md 'internal link on subtraction method'). It simply will not work if images are not compatible by bit depth, color model or size.
41+
42+
### Features
43+
44+
Currently, there are several ways of processing an image:
45+
46+
- [Filtering](../Features/Filters/Filters.md 'internal link on filters'): filters usually apply some sort of [kernel](../Glossary.md#kernel 'internal link on kernel') to change an image.
47+
48+
- [Comparison](../Features/Comparison/Comparison.md 'internal link on comparison'): these features compare two images for further feature matching between the two.
49+
50+
- [Geometry](../Features/Geometry/Geometry.md 'internal link on geometry'): this part of ImageJS allows rotating and resizing an image.
51+
52+
- [Morphology](../Features/Morphology/Morphology.md 'internal link on morphology'): enables shape analysis and shape identification.
53+
54+
<ImageDemo />

docs/Basics/Working with Masks.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import ThresholdMaskDemo from './thresholdMask.demo.tsx'
2+
import CannyMaskDemo from './cannyEdgeMask.demo.tsx'
3+
4+
Masks are binary images which are used for filtering or isolating specific regions of interest within an image for processing and analysis.
5+
6+
### Create a Mask object
7+
8+
In ImageJS there are three ways of creating a mask.
9+
First method for creating a mask is creating a Mask object. It is the easiest way, but once applied on the image, such mask will not affect it in any way, so it needs to be additionally customized by user.
10+
11+
```ts
12+
const mask = new Mask(500, 500); // Creates a simple mask filled with 0s of size 500x500.
13+
```
14+
15+
#### Options
16+
17+
| Property | Required | Default value |
18+
| --------------------------------------------------------------------------------------------- | -------- | ---------------------- |
19+
| [`origin`](https://image-js.github.io/image-js-typescript/interfaces/MaskOptions.html#origin) | no | `{row: 0, column: 0 }` |
20+
| [`data`](https://image-js.github.io/image-js-typescript/interfaces/MaskOptions.html#data) | no | - |
21+
22+
### Use `threshold()` method
23+
24+
Another approach is to obtain a mask by using [`threshold` method](../Features/Operations/Threshold.md 'internal link on threshold') on an image.
25+
26+
```ts
27+
image = image.threshold(); // returns a mask
28+
```
29+
30+
In most cases, thresholding is your go-to method to get a mask from an image.
31+
32+
<ThresholdMaskDemo />
33+
34+
:::tip
35+
`threshold()`method possesses different algorithms which can affect the mask output. It is better to try several of them to see which one fits your needs best. For instance the demo above uses [`'otsu'`](https://en.wikipedia.org/wiki/Otsu%27s_method 'wikipedia link on otsu') algorithm.
36+
:::
37+
38+
### Use `cannyEdgeDetector()` method
39+
40+
There is also a third way to get a mask. It is to use [`cannyEdgeDetector` method](../Features/Morphology/Canny%20Edge%20Detector.md).
41+
42+
```ts
43+
image = image.cannyEdgeDetector(); // returns a mask
44+
```
45+
46+
<CannyMaskDemo />
47+
48+
Canny Edge detection is useful when there is a need to determine edges of the elements. Elements with a change of intensity are colored white, while regions with no change are colored black.

docs/Basics/Working with ROIs.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
_A region of interest (ROI) represents an area of contiguous pixels within the dimensions of an image._
2+
3+
There are currently two ways ROIs can be generated in ImageJS:
4+
5+
- From [masks](./Working%20with%20Masks.md 'internal link on working with mask') by identifying contiguous black or white pixels within it.
6+
<!-- TODO: add links to the relevant sections once they exist -->
7+
- By identifying starting points of interest (for example by finding and filtering local extrema) and running the watershed algorithm on them.
8+
9+
ROIs identify and characterize regions within images, which has wide applications in image analysis.
10+
11+
```ts
12+
import { fromMask } from 'image-js';
13+
14+
// Get the list of ROIs representing the white regions of the mask
15+
const rois = fromMask(mask).getRois();
16+
```
17+
18+
In general you don't need to worry about the intermediate object returned by `fromMask()`. You will mostly be working with the list of ROIs returned by `getRois()`. It contains all the useful properties which characterize the regions of interest, such as surface, perimeter, centroid etc.
19+
20+
:::tip
21+
In the options parameter,`getRois()` has a `kind` option which tells what kind of regions to return.
22+
23+
| `kind` option | What it does |
24+
| ------------- | -------------------------- |
25+
| `'bw'` | returns all the regions |
26+
| `'black'` | returns only black regions |
27+
| `'white'` | returns only white regions |
28+
29+
:::
30+
Let's take a look at a real life example.
31+
Here you have an image of particles under electron microscopy magnified where 1px = 0.2727 nm. Let's say we want to get the data about all the regions presented on the image and calculate their Feret diameters.
32+
33+
![input image](./roiImages/inputImage.png)
34+
35+
It can be done with with following code:
36+
37+
```ts
38+
import { Image, fromMask } from 'image-js';
39+
40+
//Convert image to grayscale, then apply a blur on it. This will smooth out the noise and avoid creating many small ROIs in the next steps(image 1).
41+
const image = sourceImage.grey().blur({ width: 5, height: 5 });
42+
//Use threshold to convert the grayscale image to a Mask. The default threshold algorithm is Otsu which will automatically determine the threshold between black and white pixels by minimizing intra-class intensity variance(image 2).
43+
const mask = image.threshold();
44+
45+
//Receive all the regions of interest from mask(colored on image 3).
46+
const roiMap = fromMask(mask);
47+
const rois = roiMap.getRois({ kind: 'black' });
48+
49+
for (const roi of rois) {
50+
//Get Feret diameters for each ROI(colored on image 4)
51+
const feret = roi.feret;
52+
}
53+
```
54+
55+
Each region of interest possesses many properties and characteristics (ROIs are highlighted in blue on Image 3).
56+
Feret diameter is a rather advanced property, but there are also more general and basic ones, like surface or perimeter.
57+
58+
![combination of images](./roiImages/comboImage.png)
59+
60+
If you need a further insight on ROIs level of elongation and shape, however, you can use Feret diameter by calling it with `roi.feret`.
61+
In our current example, they are represented as two green segments(Image 4).
62+
63+
Properties shown here only represent a part of what ImageJS analysis is capable of. To learn more about our analysis tools you can visit Analysis section.

docs/Basics/_category_.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"position": 10
3+
}

docs/Basics/cannyEdgeMask.demo.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Image } from 'image-js';
2+
3+
export default function maskDemo(image: Image) {
4+
let mask = image.grey().cannyEdgeDetector();
5+
return mask;
6+
}

docs/Basics/image.demo.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Image } from 'image-js';
2+
3+
export default function ImageDemo(image: Image) {
4+
let mask = image.invert();
5+
return mask;
6+
}

docs/Basics/roi.demo.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Image, fromMask } from 'image-js';
2+
3+
export default function roiDemo(image: Image) {
4+
let mask = image.blur({ width: 3, height: 3 }).grey().threshold();
5+
let roiMap = fromMask(mask);
6+
let rois = roiMap.getRois();
7+
for (let roi of rois) {
8+
image = image.paintMask(roi.getMask(), {
9+
origin: { column: roi.origin.column, row: roi.origin.row },
10+
color: [0, 0, 255],
11+
});
12+
}
13+
14+
return image;
15+
}

docs/Basics/roiImages/comboImage.png

1.32 MB
Loading

0 commit comments

Comments
 (0)