Hide keyboard shortcuts

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 

3 

4"""RIM-ONE r3 (training set) for Cup Segmentation 

5 

6The dataset contains 159 stereo eye fundus images with a resolution of 2144 x 

71424. The right part of the stereo image is disregarded. Two sets of 

8ground-truths for optic disc and optic cup are available. The first set is 

9commonly used for training and testing. The second set acts as a “human” 

10baseline. A third set, composed of annotation averages may also be used for 

11training and evaluation purposes. 

12 

13* Reference: [RIMONER3-2015]_ 

14* Original resolution (height x width): 1424 x 1072 

15* Split reference: [MANINIS-2016]_ 

16* Protocols ``optic-disc-exp1``, ``optic-cup-exp1``, ``optic-disc-exp2``, 

17 ``optic-cup-exp2``, ``optic-disc-avg`` and ``optic-cup-avg``: 

18 

19 * Training: 99 

20 * Test: 60 

21""" 

22 

23import os 

24 

25import pkg_resources 

26 

27import bob.extension 

28 

29from ..dataset import JSONDataset 

30from ..loader import load_pil_1, load_pil_rgb, make_delayed 

31 

32_protocols = [ 

33 pkg_resources.resource_filename(__name__, "optic-disc-exp1.json"), 

34 pkg_resources.resource_filename(__name__, "optic-cup-exp1.json"), 

35 pkg_resources.resource_filename(__name__, "optic-disc-exp2.json"), 

36 pkg_resources.resource_filename(__name__, "optic-cup-exp2.json"), 

37 pkg_resources.resource_filename(__name__, "optic-disc-avg.json"), 

38 pkg_resources.resource_filename(__name__, "optic-cup-avg.json"), 

39] 

40 

41_root_path = bob.extension.rc.get( 

42 "bob.ip.binseg.rimoner3.datadir", os.path.realpath(os.curdir) 

43) 

44_pkg_path = pkg_resources.resource_filename(__name__, "masks") 

45 

46 

47def _raw_data_loader(sample): 

48 # RIM-ONE r3 provides stereo images - we clip them here to get only the 

49 # left part of the image, which is also annotated 

50 return dict( 

51 data=load_pil_rgb(os.path.join(_root_path, sample["data"])).crop( 

52 (0, 0, 1072, 1424) 

53 ), 

54 label=load_pil_1(os.path.join(_root_path, sample["label"])).crop( 

55 (0, 0, 1072, 1424) 

56 ), 

57 mask=load_pil_1(os.path.join(_pkg_path, sample["mask"])).crop( 

58 (0, 0, 1072, 1424) 

59 ), 

60 ) 

61 

62 

63def _loader(context, sample): 

64 # "context" is ignored in this case - database is homogeneous 

65 # we returned delayed samples to avoid loading all images at once 

66 return make_delayed(sample, _raw_data_loader) 

67 

68 

69dataset = JSONDataset( 

70 protocols=_protocols, 

71 fieldnames=("data", "label", "mask"), 

72 loader=_loader, 

73) 

74"""RIM-ONE r3 dataset object"""