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

## Activity
43 44 45 46 47 48
<details open>
<summary>Jython script</summary>
<br>
```python
from ij import IJ, ImagePlus
from ij.plugin import Thresholder
Christian Tischer's avatar
Christian Tischer committed
49

Christian Tischer's avatar
Christian Tischer committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
Open an image and binarize it by applying a threshold.

<details>
 <summary>ImageJ user interface</summary>
	- `Open...`
		- "/image-analysis-training-resources/image_data/xy_8bit__two_cells.tif";
  	- `Threshold...` 
</details>

<details>
 <summary>ImageJ macro</summary>
  open("/image-analysis-training-resources/image_data/xy_8bit__two_cells.tif");
  setThreshold(30, 255);
  setOption("BlackBackground", true);
  run("Convert to Mask");
</details>



Christian Tischer's avatar
Christian Tischer committed
69

70 71 72 73 74 75 76 77 78 79
inputImage=IJ.getImage()

IJ.setRawThreshold(inputImage, 60, 255, None)

binaryImage=ImagePlus('Binary image',Thresholder.createMask(inputImage))

binaryImage.show()
```
</details>

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

Quizz or something

## Follow-up material

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

## Learn more

External links...