IPSDK 0.2
IPSDK : Image Processing Software Development Kit
void putROI2dImg (inOutImg,inRoiImg,xOffset,yOffset)
void putROI2dImg (inImg,inRoiImg,xOffset,yOffset,outImg)

Detailed Description

Algorithm allowing to set the the 2d ROI of an image with the content of another image.

This algorithm to set the the 2d ROI of an image (InImg) with the content of another image (InROIImg). The ROI is delimited by a rectangle, defined by the attribute InInputImg2dOffset and by the size of the ROI image.

InImg and OutImg have the same type and size
InImg and InROIImg have the same type, and the size of InROIImg cannot exceed the size of InImg

On output image, values are given by :

\[ OutImg[x, y] = \begin{cases} InROIImg[x, y] & \text { if } x-InInputImg2dOffset::XOffset \in [0 .. InROIImgXSize-1] \text { and } y-InInputImg2dOffset::YOffset \in [0 .. InROIImgYSize-1] \\ InImg[x, y] & \text { otherwise} \end{cases} \]

,

with $InROIImgXSize$ and $InROIImgYSize$ the sizes of InROIImg image along x-axis and y-axis, respectively.

An example of 2d ROI extraction is shown below, with the following parameters:

putROI2dImg.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLUtility as util

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
inROIImg = PyIPSDK.loadTiffImageFile(inputROIImgPath)
# intialization of output image
outGeometry = PyIPSDK.geometry2d(PyIPSDK.eImageBufferType.eIBT_UInt8, 510, 509)
outImg = PyIPSDK.createImage(outGeometry)
# 2d ROI insertion
util.putROI2dImg(inImg, inROIImg, 400, 401, outImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLUtility/Processor/PutROI2dImg/PutROI2dImg.h>

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
if(pInImg->getBufferType() != imageBufferType)
pInImg = convertImg(pInImg, imageBufferType);
ImagePtr pInROIImg = loadTiffImageFile(inputROIImgPath);
if(pInROIImg->getBufferType() != imageBufferType)
pInROIImg = convertImg(pInROIImg, imageBufferType);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(pInImg->getGeometry());
// ROI insertion in image
putROI2dImg(pInImg, pInROIImg, inOffsetX, inOffsetY, pOutImg);