MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
test_interp_scale.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file test_interp_scale.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Quick test program for getPxColorInterpBLin.@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 aRamCanvas;
39 mjr::ramCanvas3c8b::colorType aColor("red");
40 int rRet;
41
42 if (argc < 2) {
43 fprintf(stderr, "ERROR argument required!\n");
44 exit(1);
45 }
46
47 if((rRet=aRamCanvas.readTIFFfile(argv[1]))) {
48 fprintf(stderr, "ERROR(%d) reading file %s\n", rRet, argv[1]);
49 exit(1);
50 }
51
52 // aRamCanvas.writeTGAfile("test_interp_scale_orig.tga");
53 // aRamCanvas.writeTGAfile("test_interp_scale_orig.tiff");
54
55 mjr::ramCanvas3c8b::coordIntType width = aRamCanvas.getNumPixX();
56 mjr::ramCanvas3c8b::coordIntType height = aRamCanvas.getNumPixY();
57 double magr = 7.0;
58 int magi = 7.0;
59
60 mjr::ramCanvas3c8b bRamCanvas(width * magi, height * magi);
61
62 for(mjr::ramCanvas3c8b::coordIntType x = 0; x < bRamCanvas.getNumPixX(); x++) {
63 for(mjr::ramCanvas3c8b::coordIntType y = 0; y < bRamCanvas.getNumPixY(); y++) {
64 aColor = aRamCanvas.getPxColorInterpTrunc(x/magi, y/magi);
65 bRamCanvas.drawPointNC(x, y, aColor);
66 }
67 }
68 bRamCanvas.writeTIFFfile("test_interp_scale_trunc.tiff");
69
70 for(mjr::ramCanvas3c8b::coordIntType x = 0; x < bRamCanvas.getNumPixX(); x++) {
71 for(mjr::ramCanvas3c8b::coordIntType y = 0; y < bRamCanvas.getNumPixY(); y++) {
72 aColor = aRamCanvas.getPxColorInterpNear(x/magi, y/magi);
73 bRamCanvas.drawPointNC(x, y, aColor);
74 }
75 }
76 bRamCanvas.writeTIFFfile("test_interp_scale_near.tiff");
77
78 for(mjr::ramCanvas3c8b::coordIntType x = 0; x < bRamCanvas.getNumPixX(); x++) {
79 for(mjr::ramCanvas3c8b::coordIntType y = 0; y < bRamCanvas.getNumPixY(); y++) {
80 aColor = aRamCanvas.getPxColorInterpBLin(x/magr, y/magr);
81 bRamCanvas.drawPointNC(x, y, aColor);
82 }
83 }
84 bRamCanvas.writeTIFFfile("test_interp_scale_bil.tiff");
85
86 for(mjr::ramCanvas3c8b::coordIntType x = 0; x < bRamCanvas.getNumPixX(); x++) {
87 for(mjr::ramCanvas3c8b::coordIntType y = 0; y < bRamCanvas.getNumPixY(); y++) {
88 aColor = aRamCanvas.getPxColorInterpAvg4(x/magr, y/magr);
89 bRamCanvas.drawPointNC(x, y, aColor);
90 }
91 }
92 bRamCanvas.writeTIFFfile("test_interp_scale_avg4.tiff");
93
94 for(mjr::ramCanvas3c8b::coordIntType x = 0; x < bRamCanvas.getNumPixX(); x++) {
95 for(mjr::ramCanvas3c8b::coordIntType y = 0; y < bRamCanvas.getNumPixY(); y++) {
96 aColor = aRamCanvas.getPxColorInterpAvg9(x/magr, y/magr);
97 bRamCanvas.drawPointNC(x, y, aColor);
98 }
99 }
100 bRamCanvas.writeTIFFfile("test_interp_scale_avg9.tiff");
101
102 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
103 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
104
105 return 0;
106}
107/** @endcond */
int main(int argc, char *argv[])