Revision 21610

View differences:

trunk/libraries/libRaster/src-test/org/gvsig/raster/buffer/TestGdalByteMultiBandHistogram.java
34 34
 * @author Nacho Brodin (nachobrodin@gmail.com)
35 35
 */
36 36
public class TestGdalByteMultiBandHistogram extends TestCase{
37
	private String baseDir = "./test-images/";
38
	private String path1   = baseDir + "band1-30x28byte.tif";
39
	private String path2   = baseDir + "band2-30x28byte.tif";
40
	private String path3   = baseDir + "band3-30x28byte.tif";
41
	private RasterDataset f1 = null, f2 = null, f3 = null;
42
	private BufferFactory ds = null;
37
	private boolean printCode = false;
38
	private String  baseDir   = "./test-images/";
39
	private String  path1     = baseDir + "band1-30x28byte.tif";
40
	private String  path2     = baseDir + "band2-30x28byte.tif";
41
	private String  path3     = baseDir + "band3-30x28byte.tif";
43 42

  
44 43
	public void start() {
45 44
		this.setUp();
......
56 55

  
57 56
	public void testStack() {
58 57
		try {
59
			f1 = RasterDataset.open(null, path1);
60
			f2 = RasterDataset.open(null, path2);
61
			f3 = RasterDataset.open(null, path3);
62
		} catch (NotSupportedExtensionException e) {
63
			return;
64
		} catch (RasterDriverException e) {
65
			return;
66
		}
67
		ds = new BufferFactory(f1);
68
		ds.addFile(f2);
69
		ds.addFile(f3);
70
		IRasterDataSource rmd = ds.getDataSource();
58
			RasterDataset f1 = RasterDataset.open(null, path1);
59
			RasterDataset f2 = RasterDataset.open(null, path2);
60
			RasterDataset f3 = RasterDataset.open(null, path3);
71 61

  
72
		Histogram histogram = null;
62
			BufferFactory ds = new BufferFactory(f1);
63
			ds.addFile(f2);
64
			ds.addFile(f3);
73 65

  
74
		try {
75
			histogram = rmd.getHistogram();
66
			IRasterDataSource rmd = ds.getDataSource();
67
			Histogram histogram = rmd.getHistogram();
76 68
			histogram = Histogram.convertHistogramToRGB(histogram);
69

  
70
			if (printCode)
71
				print(histogram);
72

  
73
			int band0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 9, 12, 23, 33, 32, 29, 17, 29, 11, 9, 9, 8, 3, 3, 3, 1, 1, 0, 1, 6, 4, 5, 3, 2, 7, 6, 10, 8, 12, 12, 4, 5, 16, 13, 11, 13, 13, 13, 21, 20, 16, 27, 14, 14, 21, 23, 20, 20, 15, 17, 12, 9, 20, 15, 7, 11, 5, 10, 6, 5, 8, 4, 10, 6, 5, 5, 4, 1, 5, 2, 3, 3, 6, 3, 3, 3, 4, 1, 1, 2, 1, 3, 0, 2, 4, 2, 1, 2, 2, 3, 3, 0, 0, 0, 0, 3, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 };
74
			for (int i = 0; i < band0.length; i++)
75
				assertEquals((int) histogram.getHistogramValue(0, i), band0[i]);
76

  
77
			int band1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 12, 17, 30, 34, 22, 17, 11, 4, 15, 11, 16, 5, 4, 5, 3, 5, 1, 2, 1, 1, 2, 1, 1, 2, 0, 1, 3, 0, 3, 1, 0, 1, 0, 2, 0, 3, 3, 4, 2, 5, 9, 5, 9, 6, 8, 6, 5, 7, 7, 5, 6, 8, 5, 12, 9, 21, 12, 18, 7, 13, 21, 13, 22, 16, 13, 13, 15, 14, 16, 14, 13, 21, 10, 4, 12, 13, 11, 15, 9, 8, 5, 5, 7, 5, 5, 6, 7, 3, 9, 5, 1, 2, 8, 2, 1, 2, 1, 1, 4, 3, 3, 3, 2, 1, 4, 3, 2, 0, 2, 2, 3, 0, 1, 3, 2, 2, 0, 1, 0, 0, 3, 2, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
78
			for (int i = 0; i < band1.length; i++)
79
				assertEquals((int) histogram.getHistogramValue(1, i), band1[i]);
80

  
81
			int band2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 5, 6, 14, 31, 28, 32, 27, 23, 12, 10, 5, 3, 2, 5, 3, 1, 2, 1, 4, 0, 1, 1, 1, 2, 1, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 1, 1, 0, 1, 1, 1, 2, 1, 3, 1, 1, 1, 0, 0, 0, 3, 1, 0, 0, 1, 4, 2, 1, 2, 3, 3, 5, 3, 5, 1, 5, 4, 3, 3, 2, 3, 4, 5, 7, 9, 2, 3, 5, 4, 3, 6, 4, 4, 4, 6, 4, 8, 10, 9, 5, 13, 6, 7, 4, 4, 7, 8, 6, 10, 7, 6, 6, 11, 9, 8, 5, 6, 8, 14, 10, 12, 11, 7, 7, 5, 8, 7, 8, 11, 10, 7, 10, 8, 8, 3, 2, 4, 1, 5, 4, 5, 6, 8, 6, 7, 8, 4, 4, 4, 5, 3, 3, 5, 5, 1, 3, 5, 4, 3, 3, 1, 2, 1, 3, 0, 2, 2, 1, 2, 5, 3, 1, 0, 2, 0, 3, 0, 1, 1, 1, 2, 0, 2, 1, 0, 0, 0, 2, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 2 };
82
			for (int i = 0; i < band2.length; i++)
83
				assertEquals((int) histogram.getHistogramValue(2, i), band2[i]);
84

  
77 85
		} catch (HistogramException e) {
78 86
			e.printStackTrace();
87
		} catch (NotSupportedExtensionException e) {
88
			e.printStackTrace();
89
		} catch (RasterDriverException e) {
90
			e.printStackTrace();
79 91
		} catch (InterruptedException e) {
80 92
			e.printStackTrace();
81 93
		}
82

  
83
//		print(histogram);
84

  
85
		int band0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 9, 12, 23, 33, 32, 29, 17, 29, 11, 9, 9, 8, 3, 3, 3, 1, 1, 0, 1, 6, 4, 5, 3, 2, 7, 6, 10, 8, 12, 12, 4, 5, 16, 13, 11, 13, 13, 13, 21, 20, 16, 27, 14, 14, 21, 23, 20, 20, 15, 17, 12, 9, 20, 15, 7, 11, 5, 10, 6, 5, 8, 4, 10, 6, 5, 5, 4, 1, 5, 2, 3, 3, 6, 3, 3, 3, 4, 1, 1, 2, 1, 3, 0, 2, 4, 2, 1, 2, 2, 3, 3, 0, 0, 0, 0, 3, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0};
86
		for (int i = 0; i < band0.length; i++)
87
			assertEquals((int) histogram.getHistogramValue(0, i), band0[i]);
88

  
89
		int band1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 12, 17, 30, 34, 22, 17, 11, 4, 15, 11, 16, 5, 4, 5, 3, 5, 1, 2, 1, 1, 2, 1, 1, 2, 0, 1, 3, 0, 3, 1, 0, 1, 0, 2, 0, 3, 3, 4, 2, 5, 9, 5, 9, 6, 8, 6, 5, 7, 7, 5, 6, 8, 5, 12, 9, 21, 12, 18, 7, 13, 21, 13, 22, 16, 13, 13, 15, 14, 16, 14, 13, 21, 10, 4, 12, 13, 11, 15, 9, 8, 5, 5, 7, 5, 5, 6, 7, 3, 9, 5, 1, 2, 8, 2, 1, 2, 1, 1, 4, 3, 3, 3, 2, 1, 4, 3, 2, 0, 2, 2, 3, 0, 1, 3, 2, 2, 0, 1, 0, 0, 3, 2, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
90
		for (int i = 0; i < band1.length; i++)
91
			assertEquals((int) histogram.getHistogramValue(1, i), band1[i]);
92

  
93
		int band2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 5, 6, 14, 31, 28, 32, 27, 23, 12, 10, 5, 3, 2, 5, 3, 1, 2, 1, 4, 0, 1, 1, 1, 2, 1, 1, 0, 1, 0, 1, 1, 0, 2, 0, 0, 0, 1, 1, 0, 1, 1, 1, 2, 1, 3, 1, 1, 1, 0, 0, 0, 3, 1, 0, 0, 1, 4, 2, 1, 2, 3, 3, 5, 3, 5, 1, 5, 4, 3, 3, 2, 3, 4, 5, 7, 9, 2, 3, 5, 4, 3, 6, 4, 4, 4, 6, 4, 8, 10, 9, 5, 13, 6, 7, 4, 4, 7, 8, 6, 10, 7, 6, 6, 11, 9, 8, 5, 6, 8, 14, 10, 12, 11, 7, 7, 5, 8, 7, 8, 11, 10, 7, 10, 8, 8, 3, 2, 4, 1, 5, 4, 5, 6, 8, 6, 7, 8, 4, 4, 4, 5, 3, 3, 5, 5, 1, 3, 5, 4, 3, 3, 1, 2, 1, 3, 0, 2, 2, 1, 2, 5, 3, 1, 0, 2, 0, 3, 0, 1, 1, 1, 2, 0, 2, 1, 0, 0, 0, 2, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 2};
94
		for (int i = 0; i < band2.length; i++)
95
			assertEquals((int) histogram.getHistogramValue(2, i), band2[i]);
96 94
	}
97 95

  
98 96
	public void print(Histogram histogram) {

Also available in: Unified diff