Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Representations/Perception/GrayScaleImage.cpp

Go to the documentation of this file.

    00001 /**
    00002  * @file GrayScaleImage.cpp
    00003  *
    00004  * Implementation of class GrayScaleImage.
    00005  */
    00006
    00007 #include "Tools/Streams/InOut.h"
    00008 #include "GrayScaleImage.h"
    00009
    00010
    00011 GrayScaleImage::GrayScaleImage()
    00012 {
    00013   for(int y = 0; y < cameraInfo.resolutionHeight; ++y)
    00014     for(int x = 0; x < cameraInfo.resolutionWidth; ++x)
    00015     {
    00016       image[y][x] = y;
    00017     }
    00018 }
    00019
    00020 GrayScaleImage::~GrayScaleImage()
    00021 {
    00022 }
    00023
    00024 void GrayScaleImage::copyChannel(const Image& yuvImage, int channel)
    00025 {
    00026   for(int y=0; y < yuvImage.cameraInfo.resolutionHeight; y++)
    00027     for(int x=0; x < yuvImage.cameraInfo.resolutionWidth; x++)
    00028       image[y][x] = yuvImage.image[y][channel][x];
    00029   this->cameraInfo = yuvImage.cameraInfo;
    00030 }
    00031
    00032 Out& operator<<(Out& stream, const GrayScaleImage& grayScaleImage)
    00033 {
    00034   stream
    00035     << grayScaleImage.cameraInfo.resolutionWidth
    00036     << grayScaleImage.cameraInfo.resolutionHeight;
    00037
    00038   for(int y = 0; y < grayScaleImage.cameraInfo.resolutionHeight; ++y)
    00039     stream.write(&grayScaleImage.image[y][0], grayScaleImage.cameraInfo.resolutionWidth);
    00040
    00041   return stream;
    00042 }
    00043
    00044 In& operator>>(In& stream, GrayScaleImage& grayScaleImage)
    00045 {
    00046   stream
    00047     >> grayScaleImage.cameraInfo.resolutionWidth
    00048     >> grayScaleImage.cameraInfo.resolutionHeight;
    00049
    00050   for(int y = 0; y < grayScaleImage.cameraInfo.resolutionHeight; ++y)
    00051     stream.read(&grayScaleImage.image[y][0], grayScaleImage.cameraInfo.resolutionWidth);
    00052
    00053   return stream;
    00054 }