Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
2# coding=utf-8
4"""Montgomery County dataset for Lung Segmentation
6The database includes 58 cases with manifestation of tuberculosis, and 80
7normal cases. It contains a total of 138 resolution of 4020 x 4892, or
84892 x 4020. One set of ground-truth lung annotations is available.
10* Reference: [MC-2014]_
11* Original resolution (height x width): 4020 x 4892, or 4892 x 4020
12* Configuration resolution: 512 x 512 (after rescaling)
13* Split reference: [GAAL-2020]_
14* Protocol ``default``:
16 * Training samples: 96 (including labels)
17 * Validation samples: 14 (including labels)
18 * Test samples: 28 (including labels)
20"""
22import os
24import numpy as np
25import pkg_resources
27from PIL import Image
29import bob.extension
31from ..dataset import JSONDataset
32from ..loader import load_pil_1, load_pil_rgb, make_delayed
34_protocols = [
35 pkg_resources.resource_filename(__name__, "default.json"),
36]
38_root_path = bob.extension.rc.get(
39 "bob.ip.binseg.montgomery.datadir", os.path.realpath(os.curdir)
40)
43def _raw_data_loader(sample):
44 return dict(
45 data=load_pil_rgb(os.path.join(_root_path, sample["data"])),
46 label=Image.fromarray(
47 np.ma.mask_or(
48 np.asarray(
49 load_pil_1(os.path.join(_root_path, sample["label_l"]))
50 ),
51 np.asarray(
52 load_pil_1(os.path.join(_root_path, sample["label_r"]))
53 ),
54 )
55 ),
56 )
59def _loader(context, sample):
60 # "context" is ignored in this case - database is homogeneous
61 # we returned delayed samples to avoid loading all images at once
62 return make_delayed(sample, _raw_data_loader)
65dataset = JSONDataset(
66 protocols=_protocols,
67 fieldnames=("data", "label_l", "label_r"),
68 loader=_loader,
69)
71"""Montgomery County dataset object"""