MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
geomTfrm_Rotate.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file geomTfrm_Rotate.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Read an image, rotate it, and write out the transformed image.@EOL
7 @copyright
8 @parblock
9 Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
14
15 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17
18 3. Neither the name of the copyright holder nor the names of its contributors may be used to edorse or promote products derived from this software
19 without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 @endparblock
28*/
29/*******************************************************************************************************************************************************.H.E.**/
30/** @cond exj */
31
32//--------------------------------------------------------------------------------------------------------------------------------------------------------------
33#include "ramCanvas.hpp"
34
35//--------------------------------------------------------------------------------------------------------------------------------------------------------------
36int main(int argc, char *argv[]) {
37 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
38 mjr::ramCanvas3c8b dRamCanvas;
39
40 if (argc < 2) {
41 fprintf(stderr, "ERROR argument required!\n");
42 exit(1);
43 }
44
45 int rRet;
46 if((rRet=dRamCanvas.readTIFFfile(argv[1]))) {
47 fprintf(stderr, "ERROR(%d) reading file %s\n", rRet, argv[1]);
48 exit(1);
49 }
50
51 // Rotate 45 degrees.
52 std::vector<double> mat {0.9238795325112867, 0.3826834323650898, 0.0, -0.3826834323650898, 0.9238795325112867, 0.0, 0.0, 0.0, 1.0};
53 double Xo = dRamCanvas.getNumPixX() / 2.0;
54 double Yo = dRamCanvas.getNumPixY() / 2.0;
55 double s = 0.55;
56
57 mjr::ramCanvas3c8b uRamCanvas = dRamCanvas.geomTfrmRevAff(mat, Xo, Yo, s);
58
59 uRamCanvas.writeTIFFfile("geomTfrm_Rotate.tiff");
60
61 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
62 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
63
64 return 0;
65}
66/** @endcond */
int main(int argc, char *argv[])