1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 ** Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef TESTINGIMAGE_H 17 #define TESTINGIMAGE_H 18 19 #include <vector> 20 #include "vec3.h" 21 #include "vec2.h" 22 23 // Implements a class for image representation. 24 class TestingImage { 25 public: 26 // Constructs a new instance with the inputImage's row and column counts. 27 // No change in size. 28 TestingImage(const unsigned char* inputImage, 29 int inputWidth, int inputHeight, 30 int inputChannels, int inputRowSpan); 31 // Constructs a new instance with an inputImage but resize it to a given 32 // new size. 33 TestingImage(const unsigned char* inputImage, 34 int inputHeight, int inputWidth, 35 int inputChannel, int inputRowSpan, 36 int newHeight, int newWidth); 37 virtual ~TestingImage(); 38 39 // Reads the pixel value of a given location. 40 int getPixelValue(int row, int column, int channel) const; 41 Vec3i getPixelValue(int row, int column) const; 42 Vec3i getPixelValue(const Vec2i &pixelPosition) const; 43 Vec3i getPixelValue(const Vec2f &pixelPosition) const; 44 getImage()45 inline const unsigned char* getImage() const { return mImage; } getWidth()46 inline int getWidth() const { return mWidth; } getHeight()47 inline int getHeight() const { return mHeight; } getChannels()48 inline int getChannels() const { return mChannels; } getRowSpan()49 inline int getRowSpan() const { return mRowSpan; } 50 51 // Reads the colors of a color checker in the image with the given checker 52 // coordinates including centers and radius. 53 const std::vector<Vec3f>* getColorChecker( 54 int rowStart, int rowEnd, int columnStart, int columnEnd, 55 const std::vector<std::vector< Vec2f > >* centerAddress, 56 const std::vector<std::vector< float > >* radiusAddress) const; 57 58 // Computes the luminance value of a color image. 59 bool rgbToGrayScale(unsigned char* grayLayer) const; 60 61 private: 62 unsigned char* mImage; 63 int mWidth; 64 int mHeight; 65 int mRowSpan; 66 int mChannels; 67 }; 68 69 #endif 70