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
[Metadata](../Glossary.md#metadata'internal link on metadata') represents information about various aspects of an image itself. It can be something basic such as the date when an image was taken, or something more specific like the name of the camera that the image was taken by. You can extract some metadata tags that can provide additional information about an image by using this command:
2
+
3
+
## Getting metadata from TIFF files
4
+
5
+
```ts
6
+
const meta =image.meta;
7
+
```
8
+
9
+

10
+
11
+
In ImageJS there are two supported formats for metadata: `exif` and `tiff`. While `exif` is a format used by digital images to store metadata, `tiff` is an image format used for high quality [raster graphics](https://en.wikipedia.org/wiki/Raster_graphics'wikipedia link for raster graphics') images. Since our image in question is of `tiff` format and `exif` part of returned metadata is empty we will focus on `tiff` part.
12
+
13
+
```ts
14
+
const meta =image.meta.tiff;
15
+
```
16
+
17
+
There you will have two other parts: one part will be comprised of a map with fields and then an object of TIFF meta tags which these fields' values are attributed to.
Within metadata, you might be wondering what this huge mix of letters and numbers represents:
24
+
25
+

26
+
27
+
Well, the TIFF format has a feature of adding custom metadata fields and this text is exactly these custom image information. For instance, in this case you can get information about the microscope that was used, or the magnification level or the electrometric tension that was used while the image was taken. However, this data needs to be parsed, as it is difficult to decipher in its raw format.
28
+
To do so you need to identify what is the key id of this text. In our case it is `34682`, but it might not always be the case so check it beforehand.
29
+
30
+
Next thing we need to do is to parse this text.
31
+
32
+
```ts
33
+
let metaMisc = [];
34
+
35
+
let lines =image.meta.tiff.fields.get(34682).split('</Data><Data>');
36
+
//We split each line into three elements:
37
+
//key(name of the tag)
38
+
//value(value of the tag)
39
+
//unit(units in which the value is measured).
40
+
lines.forEach((a) => {
41
+
var fields =a.split(/<\/Label><Value>|<\/Value><Unit>/);
42
+
fields[0] =fields[0].replace(/^.*>/, '');
43
+
fields[2] =fields[2].replace(/<.*$/, '');
44
+
metaMisc.push({
45
+
key: fields[0],
46
+
value: fields[1],
47
+
unit: fields[2],
48
+
});
49
+
});
50
+
```
51
+
52
+
With this the data in the console should look something like this.
53
+
54
+

55
+
56
+
### Getting pixel size
57
+
58
+
In this specific scenario we would also like to tell you about the way to calculate image's pixel size. It is an important aspect to deduce image's detail sharpness and display's quality.
59
+
Pixel size can be one of metadata fields but if this isn't the case we would like to show you how you can calculate it from the existing data in this specific scenario.
60
+
61
+
To calculate pixel size you can calculate DPI resolution and apply it with magnification.
62
+
DPI resolution represents the number of dots per inch. To calculate it we need to look at three lines in our parsed extra data: `XResolution`, `YResolution` and `ResolutionUnit`.
63
+
X and Y resolutions are the number of dots per inch on X and Y axes. So, if they are equal, then DPI resolution equals to one of these values. However, this value might not be measured in inches. To check that we need to look at the value of `ResolutionUnit`.
64
+
If its value equals to 2 then the X and Y resolutions are measured in inches.If it's 3 then it's in centimeters and has to be converted.
It is important to put origin as a parameter. If not specified, the origin of the whole image will be considered as one,so your mask will probably be painted somewhere in the top left
84
+
corner regardless of your ROI position.
85
+
:::
86
+
87
+
:::info
88
+
You can also use `paintMaskOnImage` function to do the same thing:
This provides us with a certain number of regions (colored in blue). The selected regions can be investigated further. For instance, we can use property like `roundness` to see how close the region's shape is to a circle. Let's put 0.9 as a limit (the coefficient for a perfect circle will be 1).
75
102
76
103
```ts
77
104
let roundestRois = [];
78
-
for (const roi ofbiggestRois) {
79
-
if (roi.roundness>0.9) {
80
-
roundestRois.push(roi);
81
-
}
82
-
}
105
+
const roundestRois =biggestRois.filter((roi) => {
106
+
returnroi.roundness>0.9;
107
+
});
108
+
```
109
+
110
+
After that we can paint the rois with a different color the same manner we did before to highlight the "roundest" regions.
An image above highlights the ROIs that we found. Dark blue regions represent the particles that were above the average that we calculated. The light blue particles are the particles with an above average size and roundness above 0.9.
117
158
This is just a fraction of tools that ImageJS possesses. There are many other properties that you can discover more about in our [API features](../Features/Regions%20of%20interest/Regions%20of%20interest.md) section. Here is an example of the properties that you can use with any region of interest:
118
159
@@ -135,100 +176,3 @@ This is just a fraction of tools that ImageJS possesses. There are many other pr
Another aspect worth inspecting is extracting image metadata. Metadata represents information about an image itself. It can be something basic such as the date when an image was taken, or something specific like the name of the camera that the image was taken by. You can extract some metadata tags that can provide additional information about an image by using this command:
142
-
143
-
```ts
144
-
const meta =image.meta;
145
-
```
146
-
147
-

148
-
149
-
In ImageJS there are two supported formats for metadata: `exif` and `tiff`. While `exif` is a format used by digital images to store metadata, `tiff` is an image format used for high quality [raster graphics](https://en.wikipedia.org/wiki/Raster_graphics'wikipedia link for raster graphics') images. Since our image in question is of `tiff` format and `exif` part of returned metadata is empty we will focus on `tiff` part.
150
-
151
-
```ts
152
-
const meta =image.meta.tiff;
153
-
```
154
-
155
-
There you will have two other parts: one part will be comprised of a map with fields and then an object of TIFF meta tags which these fields' values are attributed to.
Within metadata, you might be wondering what this huge mix of letters and numbers represents:
162
-
163
-

164
-
165
-
These are custom fields added with additional information about an image. For instance, in this case you can get information about the microscope that was used, or the magnification level or the electrometric tension that was used while the image was taken. However, this data needs to be parsed, as it is difficult to decipher in its raw format.
166
-
To do so you need to identify what is the key id of this text. In our case it is `34682`, but it might not always be the case so check it beforehand.
167
-
168
-
Next thing we need to do is to parse this text.
169
-
170
-
```ts
171
-
let metaMisc = [];
172
-
173
-
let lines =image.meta.tiff.fields.get(34682).split('</Data><Data>');
174
-
//We split each line into three elements:
175
-
//key(name of the tag)
176
-
//value(value of the tag)
177
-
//unit(units in which the value is measured).
178
-
lines.forEach((a) => {
179
-
var fields =a.split(/<\/Label><Value>|<\/Value><Unit>/);
180
-
fields[0] =fields[0].replace(/^.*>/, '');
181
-
fields[2] =fields[2].replace(/<.*$/, '');
182
-
metaMisc.push({
183
-
key: fields[0],
184
-
value: fields[1],
185
-
unit: fields[2],
186
-
});
187
-
});
188
-
```
189
-
190
-
With this the data in the. console should look something like this.
191
-
192
-

193
-
194
-
### Getting pixel size
195
-
196
-
In this specific scenario we would also like to tell you about the way to calculate image's pixel size. It is an important aspect to deduce image's detail sharpness and display's quality.
197
-
Pixel size can be one of metadata fields but if this isn't the case we would like to show you how you can calculate it from the existing data in this specific scenario.
198
-
199
-
To calculate pixel size you can calculate DPI resolution and apply it with magnification.
200
-
DPI resolution represents the number of dots per inch. To calculate it we need to look at three lines in our parsed extra data: `XResolution`, `YResolution` and `ResolutionUnit`.
201
-
X and Y resolutions are the number of dots per inch on X and Y axes. So, if they are equal, then DPI resolution equals to one of these values. However, this value might not be measured in inches. To check that we need to look at the value of `ResolutionUnit`.
202
-
If its value equals to 2 then the X and Y resolutions are measured in inches.If it's 3 then it's in centimeters and has to be converted.
0 commit comments