32 size_t inHeight = inImg.
height();
33 size_t singleImage_rowSizeByte = outImgL.
getRowSize();
38 for(
size_t h=0; h<inHeight; h++)
41 memcpy(pixelLeft + h*singleImage_rowSizeByte, pixelInput, singleImage_rowSizeByte);
42 memcpy(pixelRight + h*singleImage_rowSizeByte, pixelInput+=singleImage_rowSizeByte, singleImage_rowSizeByte);
45 pixelInput+= singleImage_rowSizeByte;
75 size_t singleImage_rowSizeByte = inImgL.
getRowSize();
78 unsigned char * pixelOutLeft = outImg.
getRawImage();
79 unsigned char * pixelOutRight = outImg.
getRawImage() + singleImage_rowSizeByte;
81 size_t height = inImgL.
height();
83 for(
size_t h=0; h<height; h++)
86 memcpy(pixelOutLeft, pixelLeft, singleImage_rowSizeByte);
87 memcpy(pixelOutRight, pixelRight, singleImage_rowSizeByte);
90 pixelOutLeft += 2*singleImage_rowSizeByte;
91 pixelOutRight += 2*singleImage_rowSizeByte;
92 pixelLeft += singleImage_rowSizeByte;
93 pixelRight += singleImage_rowSizeByte;
114 const std::pair<unsigned int, unsigned int>& vertex1,
115 const std::pair<unsigned int, unsigned int>& vertex2,
123 auto tlx = std::min(vertex1.first, vertex2.first);
124 auto tly = std::min(vertex1.second, vertex2.second);
125 auto brx = std::max(vertex1.first, vertex2.first);
126 auto bry = std::max(vertex1.second, vertex2.second);
128 if (!inImg.
isPixel(brx, bry)) {
132 outImg.
resize(brx - tlx + 1, bry - tly + 1);
136 for (
unsigned int row = 0; row < outImg.
height(); row++) {
138 memcpy(pixelOut, pixelIn, outImg.
getRowSize());
static bool checkImages(const Image &bigImg, const Image &smallImg1, const Image &smallImg2)
Base class for storing images.
unsigned char * getPixelAddress(size_t x, size_t y) const
Get address of a pixel in memory.
size_t width() const
Gets width of image in pixels.
size_t getRowSize() const
Size of the underlying image buffer rows.
unsigned char * getRawImage() const
Access to the internal image buffer.
size_t getRawImageSize() const
Access to the internal buffer size information (this is how much memory has been allocated for the im...
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
bool isPixel(size_t x, size_t y) const
Check whether a coordinate lies within the image.
size_t height() const
Gets height of image in pixels.
virtual int getPixelCode() const
Gets pixel type identifier.
bool vertSplit(const yarp::sig::Image &inImg, yarp::sig::Image &outImgL, yarp::sig::Image &outImgR)
Split vertically an image in two images of the same size.
bool cropRect(const yarp::sig::Image &inImg, const std::pair< unsigned int, unsigned int > &vertex1, const std::pair< unsigned int, unsigned int > &vertex2, yarp::sig::Image &outImg)
Crop a rectangle area out of an image given two opposite vertices.
bool horzSplit(const yarp::sig::Image &inImg, yarp::sig::Image &outImgUp, yarp::sig::Image &outImgDown)
Split horizontally an image in two images of the same size.
bool vertConcat(const yarp::sig::Image &inImgUp, const yarp::sig::Image &inImgDown, yarp::sig::Image &outImg)
Concatenate vertically two images of the same size in one with double height.
bool horzConcat(const yarp::sig::Image &inImgL, const yarp::sig::Image &inImgR, yarp::sig::Image &outImg)
Concatenate horizontally two images of the same size in one with double width.