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."<