binarization.md 1.65 KB
Newer Older
Christian Tischer's avatar
Christian Tischer committed
1 2 3 4 5 6
---
title:     Image binarization
layout:    page
permalink: /binarization
---

Christian Tischer's avatar
Christian Tischer committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# Image binarization 

## Requirements

To understand this episode you need to know:

- A
- B
- C

## Motivation

Few sentences.

## Learning objectives

- Understand the relationship between an intensity image and a derived binary image.
- Execute binarization on an image.

## Concept map

28 29 30 31 32 33 34 35 36 37
<img src='https://g.gravizo.com/svg?
 digraph G {
shift [fontcolor=white,color=white];
	"pixel values" -> "foreground\n1,255" [label = " >= threshold"];
	"pixel values" -> "background\n0" [label = " < threshold"];
	"foreground\n1,255" -> "binarised pixel values"
	"background\n0" -> "binarised pixel values"
  }
'/>

Christian Tischer's avatar
Christian Tischer committed
38 39
## Example

Toby Hodges's avatar
Toby Hodges committed
40
![binarization_figure_00](/figures/binarization_concept_example.png)
Christian Tischer's avatar
Christian Tischer committed
41 42 43

## Activity

Christian Tischer's avatar
Christian Tischer committed
44 45 46 47
Open an image and binarize it by applying a threshold.

<details>
 <summary>ImageJ user interface</summary>
Aliaksandr Halavatyi's avatar
Aliaksandr Halavatyi committed
48
	
Christian Tischer's avatar
Christian Tischer committed
49 50
- **[ Open... ]** "/image-analysis-training-resources/image_data/xy_8bit__two_cells.tif" <br/>
- **[ Threshold... ]**
Christian Tischer's avatar
Christian Tischer committed
51 52 53
</details>

<details>
Christian Tischer's avatar
Christian Tischer committed
54
<summary>ImageJ macro</summary>
Aliaksandr Halavatyi's avatar
Aliaksandr Halavatyi committed
55
  
Christian Tischer's avatar
Christian Tischer committed
56 57 58 59 60 61
```
open("/image-analysis-training-resources/image_data/xy_8bit__two_cells.tif");
setThreshold(30, 255);
setOption("BlackBackground", true);
run("Convert to Mask");
```
Christian Tischer's avatar
Christian Tischer committed
62 63 64
</details>


Aliaksandr Halavatyi's avatar
Aliaksandr Halavatyi committed
65 66
<details>
<summary>Jython script</summary>
Christian Tischer's avatar
Christian Tischer committed
67

Christian Tischer's avatar
Christian Tischer committed
68
```python
Aliaksandr Halavatyi's avatar
Aliaksandr Halavatyi committed
69 70
from ij import IJ, ImagePlus
from ij.plugin import Thresholder
Christian Tischer's avatar
Christian Tischer committed
71

72 73 74 75 76
inputImage=IJ.getImage()
IJ.setRawThreshold(inputImage, 60, 255, None)
binaryImage=ImagePlus('Binary image',Thresholder.createMask(inputImage))
binaryImage.show()
```
Aliaksandr Halavatyi's avatar
Aliaksandr Halavatyi committed
77 78


79 80
</details>

Christian Tischer's avatar
Christian Tischer committed
81 82 83 84 85 86 87 88 89 90
## Formative assessment

Quizz or something

## Follow-up material

- [http:// ](next module in this repo)

## Learn more

Aliaksandr Halavatyi's avatar
Aliaksandr Halavatyi committed
91
External links...