Example a/testing/image_processing_2D: Image processing tests.

This example runs each of the filters wrapped from ITK.


The comfile run by this example is as follows:

#Example a/testing/image_processing_2D.com:  Testing all the cmiss operations with computed fields.

{
 my $filename;
 my %filter_tests;

 # Each key will generate a new test with the filename and parameters given.
 # The keys are listed alphabetically, add new filters to be tested in the
 # correct place so that missing filters can be easily identified.

 # binary dilate image filter
 $filter_tests{'binary_dilate_1.png'} = ['binary_dilate', 'dilate_value 1 radius 1'];
 $filter_tests{'binary_dilate_3.png'} = ['binary_dilate', 'dilate_value 1 radius 3'];

 # binary erode image filter
 $filter_tests{'binary_erode_1.png'} = ['binary_erode', 'erode_value 1 radius 1'];
 $filter_tests{'binary_erode_3.png'} = ['binary_erode', 'erode_value 1 radius 3'];

 # binary threshold image filter
 $filter_tests{'threshold_0.5.png'} = ['binary_threshold_filter', 'lower_threshold 0.5'];
 $filter_tests{'threshold_0.4_0.6.png'} = ['binary_threshold_filter', 'lower_threshold 0.4 upper_threshold 0.6'];

 # canny edge image filter
 $filter_tests{'canny_edge.png'} = ['canny_edge_detection_filter', ''];

 # connected threshold image filter
 $filter_tests{'connected_threshold.png'} = ['connected_threshold', 'lower_threshold 0.5 upper_threshold 1 num_seed_points 1 dimension 2 seed_points 0.5 0.2'];

 # curvature anisotropic diffusion image filter
  $filter_tests{'curvature_anisotropic_diffusion.png'} = ['curvature_anisotropic_diffusion', ''];

 # derivative image filter
 $filter_tests{'derivative_y.png'} = ['derivative', 'xi_index 2'];

 # discrete gaussian image filter
 $filter_tests{'discrete_gaussian.png'} = ['discrete_gaussian', 'variance 3 max_kernel_width 6'];

 # fast marching image filter
 $filter_tests{'fast_marching.png'} = ['fast_marching', 'num_seed_points 1 dimension 2 seed_points 0.5 0.2 '];

 # gradient magnitude recursive gaussian image filter
 $filter_tests{'gradient_magnitude_recursive_gaussian.png'} = ['gradient_magnitude_recursive_gaussian', ''];

 # histogram image filter
 $filter_tests{'histogram64.png'} = ['histogram', 'number_of_bins 64'];
 $filter_tests{'histogram8.png'} = ['histogram', 'number_of_bins 8'];
 $filter_tests{'histogram8minmax.png'} = ['histogram', 'number_of_bins 8 histogram_minimum -0.25 histogram_maximum 1.5'];

 # image resample
 $filter_tests{'resample.png'} = ['image_resample', 'sizes 64 64'];

 # mean image filter
 $filter_tests{'mean_1.png'} = ['mean_filter', 'radius_sizes 1 1'];
 $filter_tests{'mean_3.png'} = ['mean_filter', 'radius_sizes 3 3'];

 # rescale intensity image filter
 $filter_tests{'rescale_intensity.png'} = ['rescale_intensity', 'output_min 0.5 output_max 0.7'];

 # sigmoid image filter
 $filter_tests{'sigmoid_0_1_0.1_0.7.png'} = ['sigmoid_filter', 'minimum 0.0 maximum 1.0 alpha 0.1 beta 0.7'];

 # threshold filter
 $filter_tests{'threshold_below_0.3.png'} = ['threshold_filter', 'below below_value 0.3 outside_value 0.0'];
 $filter_tests{'threshold_above_0.6.png'} = ['threshold_filter', 'above above_value 0.6 outside_value 0.0'];
 $filter_tests{'threshold_outside_0.3_0.6.png'} = ['threshold_filter', 'outside below_value 0.3 above_value 0.6 outside_value 0.0'];


 sub test_filter
 {
	my $filename = shift;
	my $filter_name = shift;
	my $parameters = shift;

	print "$filter_name => $filename \'$parameters\'\n";

	cmiss::cmiss("gfx define field intermediate_image $filter_name field input_image $parameters");

	gfx modify texture output_image nearest width 1 height 1 evaluate_image field intermediate_image spectrum gray_spectrum texture_coord xi element_group square;
	gfx write texture output_image file $filename;
 }

 # Read in a mesh which is currently required for cmiss.
 gfx read nodes $example/square.exnode
 gfx read elements $example/square.exelem

 gfx create texture original image $example/cmiss_2D_test.png nearest width 1 height 1;
 gfx define field input_image sample_texture coordinate xi field original;

#Just set up a dummy image of the correct size
 gfx create texture output_image image $example/cmiss_2D_test.png specify_format i nearest width 1 height 1;

 gfx create spectrum gray_spectrum clear overwrite_colour
 gfx modify spectrum gray_spectrum linear range 0 1 extend_above extend_below monochrome colour_range 0 1 ambient diffuse component 1

 for $filename (sort keys %filter_tests)
 {
	test_filter($filename, ${$filter_tests{$filename}}[0], ${$filter_tests{$filename}}[1]);
 }

print "derivative => derivative_x.png 'xi_index 1'\n";
gfx define field intermediate_image1 derivative field input_image xi_index 1
gfx modify texture output_image nearest width 1 height 1 evaluate_image field intermediate_image1 spectrum gray_spectrum texture_coord xi element_group square;
gfx write texture output_image file derivative_x.png;
}

Files used by this example are:

Name                     Modified     Size

image_processing_2D.com 17-Mar-2014 4.6k COPYRIGHT 17-Mar-2014 504 cmiss_2D_test.png 17-Mar-2014 1.7k square.exelem 17-Mar-2014 1.5k square.exnode 17-Mar-2014 400

Download the entire example:

Name                                           Modified     Size

examples_a_testing_image_processing_2D.tar.gz 09-Mar-2016 7.4k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmgui-wxFailureSun Mar 6 00:05:57 20161
last breakMon Aug 25 13:15:00 20143
cmgui-wx-debugFailureSun Mar 6 00:09:42 20162
last breakMon Aug 25 13:00:00 20145
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:10:26 20162
last breakMon Aug 25 13:00:00 20144
cmgui-wx-debug-valgrindFailureSun Mar 6 01:26:11 201683
last breakTue Feb 24 00:31:00 201587
x86_64-linux
cmgui-wxFailureSun Mar 6 00:01:34 20160
last breakFri Aug 15 00:43:00 20141
cmgui-wx-debugFailureSun Mar 6 00:01:48 20161
last breakFri Aug 15 00:43:00 20141
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:34 20161
last breakFri Aug 15 00:43:00 20141
cmgui-wx-debug-valgrindFailureSun Mar 6 00:07:19 201668
last breakSun Mar 6 00:06:00 201668

Testing status by file:


Html last generated: Wed Mar 9 16:02:45 2016

Input last modified: Wed Mar 9 15:49:35 2016


CMISS Help / Examples / a / testing / image_processing_2D