From e702aa4e80b1581933484362c93261803fbd051d Mon Sep 17 00:00:00 2001 From: David Date: Tue, 31 Jan 2017 15:54:48 -0600 Subject: [PATCH] implemented array cropping --- stim/image/image.h | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) diff --git a/stim/image/image.h b/stim/image/image.h index b6713ac..8d44f73 100644 --- a/stim/image/image.h +++ b/stim/image/image.h @@ -521,6 +521,19 @@ public: return result; } + //crop regions given by an array of 1D index values + std::vector> crop_idx(size_t w, size_t h, std::vector idx) { + std::vector> result(idx.size()); //create an array of image files to return + for (size_t i = 0; i < idx.size(); i++) { //for each specified index point + size_t y = idx[i] / X(); //calculate the y coordinate from the 1D index (center of ROI) + size_t x = idx[i] - y * X(); //calculate the x coordinate (center of ROI) + y -= w / 2; //update x and y values to reflect the lower corner of the ROI + x -= h / 2; + result[i] = crop(x, y, w, h); //get the cropped image and store it in the result array + } + return result; + } + image srgb2lab(){ std::cout<<"ERROR stim::image::srgb2lab - function has been broken, re-implement."<