forked from zmoratto/PatchMatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_normals.cc
28 lines (22 loc) · 952 Bytes
/
draw_normals.cc
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
#include <vw/Core.h>
#include <vw/Image.h>
#include <vw/Math/Vector.h>
#include <vw/FileIO.h>
namespace vw {
template<> struct PixelFormatID<Vector2f> { static const PixelFormatEnum value = VW_PIXEL_GENERIC_2_CHANNEL; };
template<> struct PixelFormatID<Vector4f> { static const PixelFormatEnum value = VW_PIXEL_GENERIC_4_CHANNEL; };
}
using namespace vw;
int main( int argc, char **argv ) {
ImageView<Vector2f> normal_image;
read_image(normal_image, std::string(argv[1]));
ImageView<PixelRGB<uint8> > output_image(normal_image.cols(), normal_image.rows());
for ( int j = 0; j < normal_image.rows(); j++ ) {
for ( int i = 0; i < normal_image.cols(); i++ ) {
Vector2f& in = normal_image(i,j);
output_image(i,j) = PixelRGB<uint8>(PixelHSV<uint8>((255.0/3.14159)*(atan2(in.y(),in.x())+3.14159/2),255,std::min(255.0,3*255.0*norm_2(in))));
}
}
write_image("hsv_" + std::string(argv[1]), output_image);
return 0;
}