[ITK] [ITK-users] STATISTICAL FEATURES OF A 3D IMAGE

Luigi Riba ribaluigi at gmail.com
Tue Dec 15 10:32:41 EST 2015


Dear Abdelkhalek Bakkari,

to compute a bunch of statistical data about your image you could use:
itkStatisticsImageFilter
<http://www.itk.org/Doxygen/html/classitk_1_1StatisticsImageFilter.html> .
I have attached at this mail a minimal working example for 2d images.

Since you are dealing with VTK images you should probably use
itkVTKToImageFilter
<http://www.itk.org/Doxygen/html/classitk_1_1VTKImageToImageFilter.html> to
get an ITK image from a VTK one.

I am sorry, but I haven't quite understood the part regarding storing the
mean, the variance, etc as a 3D image. Anyhow, you can always build an
empty image and change its values pixel by pixel using an image iterator.

Best,

Luigi


2015-12-15 2:43 GMT+01:00 Abdelkhalek Bakkari <
bakkari.abdelkhalek at hotmail.fr>:

>
> Dear insight-users,
>
> How can I calculate the mean, variance, energy...etc of a 3D image and
> store them in an array as 3D images using ITK.
> The input 3D image is an output of VTK.
>
> Best regards,
>
> Abdelkhalek Bakkari
> Ph.D candidate in Computer Science
> Institute of Applied Computer Science
> Lodz University of Technology, Poland
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20151215/141121c0/attachment-0001.html>
-------------- next part --------------
project(statistics)
cmake_minimum_required(VERSION 2.8)

#ITK
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cxx)
target_link_libraries(${PROJECT_NAME} ${ITK_LIBRARIES})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lena512.bmp
Type: image/bmp
Size: 263222 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20151215/141121c0/attachment-0001.bin>
-------------- next part --------------
// Statistics
// Author: Luigi Riba, ribaluigi (at) gmail (dot) com
// Date: 20th December 2015

// INPUTS [OPTIONAL]
// inputImage, lena512.bmp in this case

// OUTPUTS [OPTIONAL] 
// a bunch of statistics on the image 

#include <itkImageFileReader.h>
#include <itkStatisticsImageFilter.h>

int main(int argc, char *argv[]) {

	const unsigned int Dimension = 2;
	typedef float PixelType;
	typedef itk::Image<PixelType, Dimension> ImageType;
	
	// read your image, in this case lena512.bmp
	typedef itk::ImageFileReader<ImageType> ImageReaderType;
	ImageReaderType::Pointer reader = ImageReaderType::New();
	reader->SetFileName("lena512.bmp");
	
	typedef itk::StatisticsImageFilter<ImageType> StatisticsFilterType;
	StatisticsFilterType::Pointer statistics = StatisticsFilterType::New();

	statistics->SetInput(reader->GetOutput());
	statistics->Update();
	
	// you can now get access to the computed values via the GetSomething method
	// for example:
	double mean = statistics->GetMean();

	// or you can just print all the computed values calling the Print method
	// of the object itself:
	statistics.Print(std::cout);

	system("pause");
	return EXIT_SUCCESS;

}



More information about the Community mailing list