insightsoftwareconsortium / itktexturefeatures Goto Github PK
View Code? Open in Web Editor NEWFast, Texture Feature Maps from N-Dimensional Images
Home Page: http://hdl.handle.net/10380/3574
License: Apache License 2.0
Fast, Texture Feature Maps from N-Dimensional Images
Home Page: http://hdl.handle.net/10380/3574
License: Apache License 2.0
Nice work here, I look forward to the insight journal article.
Just wanted to see if there was any interest in a filter which computed first order statistics (mean, min, max, variance, sigma, skewness, kurtosis, and entropy) over a sliding window of a scalar image. They seem very much inline with the subject of this repo.
I have an implementation here:
https://github.com/blowekamp/itkTextureAnalysis/blob/master/include/itkTextureMovingHistogramImageFilter.h
https://github.com/blowekamp/itkTextureAnalysis/blob/master/include/itkTextureHistogram.h
If you are interested an I make a pull request with these classes with tests and cleanup ( create? ) documentation for them.
I am not sure that's correct, also there is no intensity range variable to tweak that value.
Also here:
ITKTextureFeatures/include/itkCoocurrenceTextureFeaturesImageFilter.hxx
Lines 216 to 220 in 6787fc5
Hi. I am getting seg fault when I try to execute the code bellow. Any idea why?
import itk
import numpy as np
img = np.random.randint(0,256,64**3).reshape(64,64,64).astype(np.uint8)
msk = 1 + np.zeros_like(img)
img = itk.GetImageFromArray(img)
msk = itk.GetImageFromArray(msk)
filtr = itk.CoocurrenceTextureFeaturesImageFilter.New(img)
filtr.SetMaskImage(msk)
filtr.SetHistogramMinimum(0)
filtr.SetHistogramMaximum(255)
filtr.SetNeighborhoodRadius([3,3,3])
filtr.SetNumberOfBinsPerAxis(4)
result = filtr.GetOutput()
I am running with
python 3.6
itk 5.0rc2
itk-core 5.0rc2
itk-filtering 5.0rc2
itk-io 5.0rc2
itk-numerics 5.0rc2
itk-registration 5.0rc2
itk-segmentation 5.0rc2
itk-texturefeatures 3.2.1
Python 3.9.4
pip install itk -U
pip install itk-texturefeatures
ITK 5.2.0 python install + itk-texturefeatures 3.5.0 install.
help(itk.Image)
results in the following warning:
itkFixedArrayF8 not loaded from module TextureFeatures because of exception:
module 'itk.TextureFeaturesPython' has no attribute 'itkFixedArrayF8'
itkFixedArrayF10 not loaded from module TextureFeatures because of exception:
module 'itk.TextureFeaturesPython' has no attribute 'itkFixedArrayF10'
A starting point:
https://github.com/InsightSoftwareConsortium/ITKPerformanceBenchmarking/blob/master/README.rst
It should have:
[4696/5195] Generating ../../Typedefs/itkCoocurrenceTextureFeaturesIma...eFilter.idx, ../../Typedefs/itkRunLengthTextureFeaturesImageFilter.id
itkCoocurrenceTextureFeaturesImageFilter: warning(4): ITK type not wrapped, or currently not known: itk::ImageIOBase
itkRunLengthTextureFeaturesImageFilter: warning(4): ITK type not wrapped, or currently not known: itk::ImageIOBase
All classes wrapped.
Wrapping failure.
2020-03-18 master branch.
For some inputs, nan
values can appear in the output. From the few tests I did, it seems to happen with floating values and isolated points in the mask.
Minimal example:
#include "itkImage.h"
#include "itkVectorImage.h"
#include "itkCoocurrenceTextureFeaturesImageFilter.h"
typedef itk::Image<float, 2> ImageType;
typedef itk::Image<unsigned char, 2> MaskType;
typedef itk::VectorImage<float, 2> VectorType;
typedef itk::Statistics::CoocurrenceTextureFeaturesImageFilter<ImageType, VectorType> TextureType;
template<typename TImage>
typename TImage::Pointer createImage()
{
typename TImage::Pointer image = TImage::New();
typename TImage::RegionType region;
region.SetIndex({{0, 0}});
region.SetSize({{5, 5}});
image->SetRegions(region);
image->Allocate(true);
return image;
}
int main()
{
ImageType::Pointer image = createImage<ImageType>();
MaskType::Pointer mask = createImage<MaskType>();
mask->SetPixel({{2, 2}}, 1);
TextureType::Pointer texture = TextureType::New();
texture->SetInput(image);
texture->SetMaskImage(mask);
texture->Update();
std::cout << texture->GetOutput()->GetPixel({{2, 2}}) << std::endl;
}
Output:
[nan, 0, nan, nan, nan, nan, nan, nan]
The occasional test segfaults and inconsistency hopefully can be addressed by taking care of some memory access bugs identified by valgrind. These can be obtained by:
ctest -D ExperimentalMemCheck -R RunLengthTextureFeaturesImageFilterInstantiationTest -VV
, etc. Or exclude -R
to run all the tests.Testing/Temporary/MemoryChecker.*.log
Test the example build on CircleCI 2
xref #33
With the merge of #41, the C++ interface has changed the default for the mask image type. Currently, they Wrapping still specifies the mask image type to be the same as the input images. Should the wrapping be changed?
Also consider wrapping for "VectorImage" as can simplify the usage, by not needing to specify the image vector size as part of the image type.
When using an image with signed pixel type as input, the output is wrong.
Minimal example:
#include "itkImage.h"
#include "itkVectorImage.h"
#include "itkCoocurrenceTextureFeaturesImageFilter.h"
template<typename TImage>
void run()
{
typename TImage::Pointer image = TImage::New();
typename TImage::RegionType region;
region.SetIndex({{0, 0}});
region.SetSize({{5, 5}});
image->SetRegions(region);
image->Allocate(true);
using TextureType = itk::Statistics::CoocurrenceTextureFeaturesImageFilter<TImage, itk::VectorImage<float, 2>>;
typename TextureType::Pointer texture = TextureType::New();
texture->SetInput(image);
texture->Update();
std::cout << texture->GetOutput()->GetPixel({{2, 2}}) << std::endl;;
}
int main()
{
run<itk::Image<signed int, 2>>();
run<itk::Image<unsigned int, 2>>();
}
Output:
[0, 0, 0, 0, 0, 0, 0, 0]
[1, 0, 0, 1, 0, 0, 0, -0.00392157]
The problem comes from the DigitizerFunctor
, on line 80 the computing of the output range overflows.
Having ITKTextureFeatures available through conda would be much appreciated.
ref @phcerdan idea's of using new iterators in ITK5
The ITK remote module is a bit out of date now pointing to 2fed5dc.
@jbvimort I was about to bump the latest version of the ITKTextureFeatures when I realized that it has not been added as a remote to ITK yet.
I'm wondering whether it should be added as a remote to ITK, or whether you are waiting for #3 to be tackled.
May be Matt, Beatriz and/or François should may be inquired to be sure?
CC: @csheaff
256 makes computation very slow, and this is larger than the typical number of effective intensity bins encountered in many images. A better default is 8, 10, 16?
The following are missing best practices:
See 95705f5 for similar changes.
Traceback (most recent call last):
File "/home/user/a.py", line 27, in <module>
filtr = itk.CoocurrenceTextureFeaturesImageFilter.New(im)
File "/home/user/py_env/lib/python3.7/site-packages/itk/support/lazy.py", line 76, in __getattribute__
base.itk_load_swig_module(module, namespace)
File "/home/user/py_env/lib/python3.7/site-packages/itk/support/base.py", line 110, in itk_load_swig_module
l_module = loader.load(swig_module_name)
File "/home/user/py_env/lib/python3.7/site-packages/itk/support/base.py", line 259, in load
l_spec.loader.exec_module(l_module) # pytype: disable=attribute-error
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/py_env/lib/python3.7/site-packages/itk/support/../TextureFeaturesPython.py", line 74, in <module>
from itk.itkCoocurrenceTextureFeaturesImageFilterPython import *
File "/home/user/py_env/lib/python3.7/site-packages/itk/itkCoocurrenceTextureFeaturesImageFilterPython.py", line 3563, in <module>
from itk.support import itkHelpers
ImportError: cannot import name 'itkHelpers' from 'itk.support' (unknown location)
Just updated itk package from pip to version 5.2 and I cannot run itk-texturefeatures anymore, here it's the Traceback for the example code found on this repository.
Searching a bit, I found this commit from ITK repo which deleted filter_args(object)
from itk.support.helpers
which also is referenced on itkCoocurrenceTextureFeaturesImageFilterPython.py
as from itk.support import itkHelpers
. So it was renamed from itkHelpers
to helpers
.
Also, accept_numpy_array_like_xarray()
was changed to accept_array_like_xarray_torch()
Hope this information somehow help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.