MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
geomTfrm_Arb.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_Arb.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Read an image, transform it, and write out 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//--------------------------------------------------------------------------------------------------------------------------------------------------------------
36mjr::point2d<double> funny(double x, double y) {
37 double d = 0.3*std::sin(std::hypot(x, y) / 100);
38 return mjr::point2d<double>(std::cos(d)*x+std::sin(d)*y, -std::sin(d)*x+std::cos(d)*y);
39}
40
41//--------------------------------------------------------------------------------------------------------------------------------------------------------------
42int main(int argc, char *argv[]) {
43 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
44 mjr::ramCanvas3c8b dRamCanvas;
45
46 if (argc < 2) {
47 fprintf(stderr, "ERROR argument required!\n");
48 exit(1);
49 }
50
51 int rRet;
52 if((rRet=dRamCanvas.readTIFFfile(argv[1]))) {
53 fprintf(stderr, "ERROR(%d) reading file %s\n", rRet, argv[1]);
54 exit(1);
55 }
56
57 double Xo = dRamCanvas.getNumPixX() / 2.0;
58 double Yo = dRamCanvas.getNumPixY() / 2.0;
59 double s = 0.65;
60
61 mjr::ramCanvas3c8b uRamCanvas = dRamCanvas.geomTfrmRevArb(funny, Xo, Yo, s);
62
63 uRamCanvas.writeTIFFfile("geomTfrm_Arb.tiff");
64
65 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
66 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
67
68 return 0;
69}
70/** @endcond */
int main(int argc, char *argv[])