-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_image.cpp
More file actions
48 lines (41 loc) · 1.18 KB
/
tests_image.cpp
File metadata and controls
48 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Created by sliberman on 12/08/20.
//
#include "catch.hpp"
#include "imagelib.h"
TEST_CASE( "Correlation and Gaussian filter" ) {
Image lena("lena.png");
REQUIRE_THROWS_AS(new Image("noimage"), invalid_argument);
Image filtered_lena = lena.convolve(GaussianKernel(5, 1.0));
double corr = lena.correlation(filtered_lena);
REQUIRE( corr > 0.5 ); // Correlaion test
REQUIRE( corr < 1.0 ); // Gaussian filter test
}
TEST_CASE( "Gray" ) {
Image lena("lena.png");
Image lena_gray = lena.to_grayscale();
REQUIRE(lena_gray.get_channels() == 1);
}
TEST_CASE( "Edge detection" ) {
Image lena("lena.png");
Image gray = lena.to_grayscale();
Image edge = gray.detect_edges();
REQUIRE(edge.get_channels() == 1);
}
TEST_CASE( "Copy image" ) {
Image lena("lena.png");
Image copy = lena;
REQUIRE(lena.at(10, 15)[2] == copy.at(10, 15)[2]);
copy.show();
}
TEST_CASE( "Resize image" ) {
Image lena("lena.png");
Image resized = lena.resize(123, 321);
REQUIRE(resized.get_height() == 321);
REQUIRE(resized.get_width() == 123);
}
TEST_CASE( "Show" ) {
Image lena("lena.png");
Image gray = lena.to_grayscale();
gray.show();
}