<commit_before>/*
 * Image.hpp
 *
 *  Created on: Sep 8, 2009
 *      Author: rasmussn
 */

#ifndef IMAGE_HPP_
#define IMAGE_HPP_

#include "HyPerLayer.hpp"
#include "../columns/HyPerCol.hpp"

namespace PV {

class Image : public HyPerLayer {

protected:
   Image(const char * name, HyPerCol * hc);
   virtual int initializeV(bool restart_flag);

public:
   Image(const char * name, HyPerCol * hc, const char * filename);
   virtual ~Image();

   virtual int initializeImage(const char * filename);

   // primary layer interface
   //
   virtual int recvSynapticInput(HyPerConn * conn, PVLayerCube * cube, int neighbor);
   virtual int updateState(float time, float dt);
   virtual int outputState(float time, bool last=false);

   // partially override implementation of LayerDataInterface interface
   //
   const pvdata_t * getLayerData()   { return data; }

   virtual int  clearImage();

   float lastUpdate()  { return lastUpdateTime; }

   virtual pvdata_t * getImageBuffer();
   virtual PVLayerLoc getImageLoc();

   virtual int tag();

   int read(const char * filename);
   int read(const char * filename, int offsetX, int offsetY);
   int write(const char * filename);

   int exchange();

   int toGrayScale();
   static unsigned char * convertToGrayScale(unsigned char * buf, int nx, int ny, int numBands);

   int  convolve(int width);
   void setTau(float t)                { tau = t; }

   int copyFromInteriorBuffer(unsigned char * buf, float fac);
   int copyToInteriorBuffer(unsigned char * buf, float fac);

protected:

#ifdef PV_USE_OPENCL
   virtual int initializeThreadBuffers();
   virtual int initializeThreadKernels();
#endif

   //int initializeImage(const char * filename);

   MPI_Datatype * mpi_datatypes;  // MPI datatypes for boundary exchange

   pvdata_t * data;       // buffer containing reduced image
   char * filename;       // path to file if a file exists

   PVLayerLoc imageLoc;   // size/location of actual image
   pvdata_t * imageData;  // buffer containing image

   int writeImages;      // controls writing of image file during outputState
   // bool useGrayScale;    // whether to convert image to grayscale
   // useGrayScale no longer used; instead setting nf=1 in params with color input images calls toGrayScale()
   int offsetX;          // offset of layer section within full image frame
   int offsetY;

   float lastPhase;
   float lastUpdateTime; // time of last image update

   float tau;
};

}

#endif /* IMAGE_HPP_ */<commit_msg>Added public get methods for filename, offsetX, offsetY<commit_after>/*
 * Image.hpp
 *
 *  Created on: Sep 8, 2009
 *      Author: rasmussn
 */

#ifndef IMAGE_HPP_
#define IMAGE_HPP_

#include "HyPerLayer.hpp"
#include "../columns/HyPerCol.hpp"

namespace PV {

class Image : public HyPerLayer {

protected:
   Image(const char * name, HyPerCol * hc);
   virtual int initializeV(bool restart_flag);

public:
   Image(const char * name, HyPerCol * hc, const char * filename);
   virtual ~Image();

   virtual int initializeImage(const char * filename);

   // primary layer interface
   //
   virtual int recvSynapticInput(HyPerConn * conn, PVLayerCube * cube, int neighbor);
   virtual int updateState(float time, float dt);
   virtual int outputState(float time, bool last=false);

   // partially override implementation of LayerDataInterface interface
   //
   const pvdata_t * getLayerData()   { return data; }

   virtual int  clearImage();

   float lastUpdate()  { return lastUpdateTime; }

   virtual pvdata_t * getImageBuffer();
   virtual PVLayerLoc getImageLoc();

   virtual int tag();

   int read(const char * filename);
   int read(const char * filename, int offsetX, int offsetY);
   int write(const char * filename);

   int exchange();

   int toGrayScale();
   static unsigned char * convertToGrayScale(unsigned char * buf, int nx, int ny, int numBands);

   int  convolve(int width);
   // void setTau(float t)                { tau = t; }

   int copyFromInteriorBuffer(unsigned char * buf, float fac);
   int copyToInteriorBuffer(unsigned char * buf, float fac);

   const char * getFilename() { return filename; }
   int getOffsetX() { return offsetX; }
   int getOffsetY() { return offsetY; }

protected:

#ifdef PV_USE_OPENCL
   virtual int initializeThreadBuffers();
   virtual int initializeThreadKernels();
#endif

   //int initializeImage(const char * filename);

   MPI_Datatype * mpi_datatypes;  // MPI datatypes for boundary exchange

   pvdata_t * data;       // buffer containing reduced image
   char * filename;       // path to file if a file exists

   PVLayerLoc imageLoc;   // size/location of actual image
   pvdata_t * imageData;  // buffer containing image

   int writeImages;      // controls writing of image file during outputState
   // bool useGrayScale;    // whether to convert image to grayscale
   // useGrayScale no longer used; instead setting nf=1 in params with color input images calls toGrayScale()
   int offsetX;          // offset of layer section within full image frame
   int offsetY;

   float lastPhase;
   float lastUpdateTime; // time of last image update

   // float tau;  // tau is not used by image or any subclasses
};

}

#endif /* IMAGE_HPP_ */
{'fraction_non_alphanumeric': 0.08900824860924611, 'fraction_numerical': 0.002301937464032227, 'mean_word_length': 3.291358024691358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4292700', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1486, 'n_words': 539}