summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJonathan L Long <jonlong@cs.berkeley.edu>2014-12-27 01:44:36 -0800
committermax argus <argus.max@gmail.com>2016-03-05 14:59:51 +0000
commit64e78bdc76b8cabdf4282506438ab2d7f321adf3 (patch)
tree2a921fd5b6934263de0fdd640c0904c261bce3c8 /include
parent6a0b98768d4745714e31949b87382ff562be6724 (diff)
downloadcaffe-64e78bdc76b8cabdf4282506438ab2d7f321adf3.tar.gz
caffe-64e78bdc76b8cabdf4282506438ab2d7f321adf3.tar.bz2
caffe-64e78bdc76b8cabdf4282506438ab2d7f321adf3.zip
add CropLayer: crop blob to another blob's dimensions with offsets
configure offset(s) through proto definition.
Diffstat (limited to 'include')
-rw-r--r--include/caffe/layers/crop_layer.hpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/include/caffe/layers/crop_layer.hpp b/include/caffe/layers/crop_layer.hpp
new file mode 100644
index 00000000..bab29071
--- /dev/null
+++ b/include/caffe/layers/crop_layer.hpp
@@ -0,0 +1,49 @@
+#ifndef CAFFE_CROP_LAYER_HPP_
+#define CAFFE_CROP_LAYER_HPP_
+
+#include <utility>
+#include <vector>
+
+#include "caffe/blob.hpp"
+#include "caffe/layer.hpp"
+#include "caffe/proto/caffe.pb.h"
+
+namespace caffe {
+
+/**
+ * @brief Takes a Blob and crop it along either the width or height dimension,
+ * outputting a cropped Blob.
+ *
+ * TODO(dox): thorough documentation for Forward, Backward, and proto params.
+ */
+
+template <typename Dtype>
+class CropLayer : public Layer<Dtype> {
+ public:
+ explicit CropLayer(const LayerParameter& param)
+ : Layer<Dtype>(param) {}
+ virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+ const vector<Blob<Dtype>*>& top);
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
+ const vector<Blob<Dtype>*>& top);
+
+ virtual inline const char* type() const { return "Crop"; }
+ virtual inline int ExactNumBottomBlobs() const { return 2; }
+ virtual inline int ExactNumTopBlobs() const { return 1; }
+
+ protected:
+ virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
+ const vector<Blob<Dtype>*>& top);
+ virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
+ const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
+ virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
+ const vector<Blob<Dtype>*>& top);
+ virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
+ const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
+
+ int crop_h_, crop_w_;
+};
+
+} // namespace caffe
+
+#endif // CAFFE_CROP_LAYER_HPP_