IPSDK 4.1.0.2
IPSDK : Image Processing Software Development Kit
Law's 2D Texture Energy Measures
imagelawTexture2dImg (inImg)
imagelawTexture2dImg (inImg,inKernelTypes,inPreProcParams,inPostProcParams)

Detailed Description

Apply Law's texture 2d filter on an image.

Law's texture filter generates texture features to quantify the perceived 2D textures of an image.

Law's texture 2D filter involves the following steps:

Resulting energy maps are concatenated in the output sequence image in the order specified above. Most of the time, only a subset of the 9 energy maps are interesting. The user has the possibility to specify this subset by appropriately initializing a ipsdk::imaproc::attr::LawTextureKernel2dTypes data-item and passing it as argument of lawTexture2dImg function. Then only the maps of this subset will be calculated by the algorithm and returned to the user.

Here is an example of a Law's 2D Texture Filter computation applied on a 8 bits grey level image with the default parameters:

lawTexture2dImg.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLStats as stats

Code Example

# load input image from file
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# scenario 1: compute the Law's 2D texture energy measures with default parameters:
# - pre-process phasis: subtract local mean (square neighborhood of size 15x15)
# - post-process phasis: compute energy maps using a local mean on absolute values (square neighborhood of size 15x15)
# - get all 9 energy maps
outImg = stats.lawTexture2dImg(inImg)
# extract E5E5 energy map from output image; this is the fourth image in temporal sequence
# (remember, the 9 images are ordered in sequence as follows: L5E5/E5L5, L5S5/S5L5, L5R5/R5L5, E5E5, E5S5/S5E5, E5R5/R5E5, S5S5, S5R5/R5S5, R5R5)
outImgE5E5 = PyIPSDK.extractPlan(0, 0, 3, outImg)
# scenario 2: compute the Law's 2D texture energy measures with customized parameters:
# - pre-process phasis: subtract value resulting from local gaussian smoothing with (gaussianStdDev=0.7, gaussianRatio=0.991)
# - post-process phasis: compute, for each pixel local variance on a square neighborhood of size 17x17 (17 = 2*8 + 1)
# - get the following subset of energy maps: {E5E5, R5R5}
preProcParams = PyIPSDK.createGaussianLawTexPreProcParams(0.7, PyIPSDK.createGaussianCoverage(0.991, 2))
postProcParams = PyIPSDK.createVarianceLawTexPostProcParams(8)
kernelTypes = PyIPSDK.createLawTextureKernel2dTypes()
# by default, all the flags are set to true, so reset all flags but FlagE5E5 and FlagR5R5
kernelTypes.flagL5E5_E5L5 = False
kernelTypes.flagL5S5_S5L5 = False
kernelTypes.flagL5R5_R5L5 = False
kernelTypes.flagE5S5_S5E5 = False
kernelTypes.flagE5R5_R5E5 = False
kernelTypes.flagS5S5 = False
kernelTypes.flagS5R5_R5S5 = False
outImg = stats.lawTexture2dImg(inImg, kernelTypes, preProcParams, postProcParams);
# extract E5E5 energy map from output image (this is the first image in temporal sequence)
outImgE5E5 = PyIPSDK.extractPlan(0, 0, 0, outImg)
# extract R5R5 energy map from output image (this is the second image in temporal sequence)
outImgR5R5 = PyIPSDK.extractPlan(0, 0, 0, outImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLStats/Processor/LawTexture2dImg/LawTexture2dImg.h>

Code Example

// load input image from file
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// scenario 1: compute the Law's 2D texture energy measures with default parameters:
// - pre-process phasis: subtract local mean (square neighborhood of size 15x15)
// - post-process phasis: compute energy maps using a local mean on absolute values (square neighborhood of size 15x15)
// - get all 9 energy maps
{
ImagePtr pOutImg = stats::lawTexture2dImg(pInImg);
// extract E5E5 energy map from output image; this is the fourth image in temporal sequence
// (remember, the 9 images are ordered in sequence as follows: L5E5/E5L5, L5S5/S5L5, L5R5/R5L5, E5E5, E5S5/S5E5, E5R5/R5E5, S5S5, S5R5/R5S5, R5R5)
ImagePtr pOutImgE5E5;
image::SubImageExtractor::extractPlan(0, 0, 3, *pOutImg, pOutImgE5E5);
}
// scenario 2: compute the Law's 2D texture energy measures with customized parameters:
// - pre-process phasis: subtract value resulting from local gaussian smoothing with (gaussianStdDev=0.7, gaussianRatio=0.991)
// - post-process phasis: compute, for each pixel local variance on a square neighborhood of size 17x17 (17 = 2*8 + 1)
// - get the following subset of energy maps: {E5E5, R5R5}
{
attr::LawTextureKernel2dTypesPtr pKernelTypes = attr::createLawTextureKernel2dTypes();
// by default, all the flags are set to true, so reset all flags but FlagE5E5 and FlagR5R5
pKernelTypes->setValue<LawTextureKernel2dTypes::FlagL5E5_E5L5>(false);
pKernelTypes->setValue<LawTextureKernel2dTypes::FlagL5S5_S5L5>(false);
pKernelTypes->setValue<LawTextureKernel2dTypes::FlagL5R5_R5L5>(false);
pKernelTypes->setValue<LawTextureKernel2dTypes::FlagE5S5_S5E5>(false);
pKernelTypes->setValue<LawTextureKernel2dTypes::FlagE5R5_R5E5>(false);
pKernelTypes->setValue<LawTextureKernel2dTypes::FlagS5S5>(false);
pKernelTypes->setValue<LawTextureKernel2dTypes::FlagS5R5_R5S5>(false);
ImagePtr pOutImg = stats::lawTexture2dImg(pInImg, pKernelTypes, pPreProcParams, pPostProcParams);
// extract E5E5 energy map from output image (this is the first image in temporal sequence)
ImagePtr pOutImgE5E5;
image::SubImageExtractor::extractPlan(0, 0, 0, *pOutImg, pOutImgE5E5);
// extract R5R5 energy map from output image (this is the second image in temporal sequence)
ImagePtr pOutImgR5R5;
image::SubImageExtractor::extractPlan(0, 0, 0, *pOutImg, pOutImgR5R5);
}