<s> from __future__ import division <EOL> import random <EOL> import numpy as np <EOL> from numpy . testing import assert_allclose <EOL> from nose . plugins . attrib import attr <EOL> from menpo . image import Image , MaskedImage <EOL> from menpo . feature import hog , lbp , es , igo , daisy <EOL> import menpo . io as mio <EOL> def test_imagewindowiterator_hog_padding ( ) : <EOL> n_cases = <NUM_LIT:5> <EOL> image_width = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> image_height = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_horizontal = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_vertical = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = MaskedImage ( np . random . randn ( <NUM_LIT:1> , image_height [ i , <NUM_LIT:0> ] , <EOL> image_width [ i , <NUM_LIT:0> ] ) ) <EOL> hog_im = hog ( image , mode = '<STR_LIT>' , <EOL> window_step_vertical = window_step_vertical [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal = window_step_horizontal [ i , <NUM_LIT:0> ] , <EOL> window_step_unit = '<STR_LIT>' , padding = True ) <EOL> n_windows_horizontal = len ( range ( <NUM_LIT:0> , image_width [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal [ i , <NUM_LIT:0> ] ) ) <EOL> n_windows_vertical = len ( range ( <NUM_LIT:0> , image_height [ i , <NUM_LIT:0> ] , <EOL> window_step_vertical [ i , <NUM_LIT:0> ] ) ) <EOL> assert_allclose ( hog_im . shape , ( n_windows_vertical , <EOL> n_windows_horizontal ) ) <EOL> def test_windowiterator_hog_no_padding ( ) : <EOL> n_cases = <NUM_LIT:5> <EOL> image_width = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> image_height = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_horizontal = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_vertical = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_width = np . random . randint ( <NUM_LIT:3> , <NUM_LIT:20> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_height = np . random . randint ( <NUM_LIT:3> , <NUM_LIT:20> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = MaskedImage ( np . random . randn ( <NUM_LIT:1> , image_height [ i , <NUM_LIT:0> ] , <EOL> image_width [ i , <NUM_LIT:0> ] ) ) <EOL> hog_img = hog ( image , mode = '<STR_LIT>' , cell_size = <NUM_LIT:3> , block_size = <NUM_LIT:1> , <EOL> window_height = window_height [ i , <NUM_LIT:0> ] , <EOL> window_width = window_width [ i , <NUM_LIT:0> ] , window_unit = '<STR_LIT>' , <EOL> window_step_vertical = window_step_vertical [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal = window_step_horizontal [ i , <NUM_LIT:0> ] , <EOL> window_step_unit = '<STR_LIT>' , padding = False ) <EOL> n_windows_horizontal = len ( range ( window_width [ i , <NUM_LIT:0> ] - <NUM_LIT:1> , <EOL> image_width [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal [ i , <NUM_LIT:0> ] ) ) <EOL> n_windows_vertical = len ( range ( window_height [ i , <NUM_LIT:0> ] - <NUM_LIT:1> , <EOL> image_height [ i , <NUM_LIT:0> ] , <EOL> window_step_vertical [ i , <NUM_LIT:0> ] ) ) <EOL> assert_allclose ( hog_img . shape , ( n_windows_vertical , <EOL> n_windows_horizontal ) ) <EOL> def test_windowiterator_lbp_padding ( ) : <EOL> n_cases = <NUM_LIT:5> <EOL> image_width = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> image_height = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_horizontal = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_vertical = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = MaskedImage ( np . random . randn ( <NUM_LIT:1> , image_height [ i , <NUM_LIT:0> ] , <EOL> image_width [ i , <NUM_LIT:0> ] ) ) <EOL> lbp_img = lbp ( image , window_step_vertical = window_step_vertical [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal = window_step_horizontal [ i , <NUM_LIT:0> ] , <EOL> window_step_unit = '<STR_LIT>' , padding = True ) <EOL> n_windows_horizontal = len ( range ( <NUM_LIT:0> , image_width [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal [ i , <NUM_LIT:0> ] ) ) <EOL> n_windows_vertical = len ( range ( <NUM_LIT:0> , image_height [ i , <NUM_LIT:0> ] , <EOL> window_step_vertical [ i , <NUM_LIT:0> ] ) ) <EOL> assert_allclose ( lbp_img . shape , ( n_windows_vertical , <EOL> n_windows_horizontal ) ) <EOL> def test_windowiterator_lbp_no_padding ( ) : <EOL> n_cases = <NUM_LIT:5> <EOL> image_width = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> image_height = np . random . randint ( <NUM_LIT:50> , <NUM_LIT> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_horizontal = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> window_step_vertical = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> radius = np . random . randint ( <NUM_LIT:3> , <NUM_LIT:5> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = Image ( np . random . randn ( <NUM_LIT:1> , image_height [ i , <NUM_LIT:0> ] , <EOL> image_width [ i , <NUM_LIT:0> ] ) ) <EOL> lbp_img = lbp ( image , radius = radius [ i , <NUM_LIT:0> ] , samples = <NUM_LIT:8> , <EOL> window_step_vertical = window_step_vertical [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal = window_step_horizontal [ i , <NUM_LIT:0> ] , <EOL> window_step_unit = '<STR_LIT>' , padding = False ) <EOL> window_size = <NUM_LIT:2> * radius [ i , <NUM_LIT:0> ] + <NUM_LIT:1> <EOL> n_windows_horizontal = len ( range ( window_size - <NUM_LIT:1> , image_width [ i , <NUM_LIT:0> ] , <EOL> window_step_horizontal [ i , <NUM_LIT:0> ] ) ) <EOL> n_windows_vertical = len ( range ( window_size - <NUM_LIT:1> , image_height [ i , <NUM_LIT:0> ] , <EOL> window_step_vertical [ i , <NUM_LIT:0> ] ) ) <EOL> assert_allclose ( lbp_img . shape , ( n_windows_vertical , <EOL> n_windows_horizontal ) ) <EOL> def test_hog_channels_dalaltriggs ( ) : <EOL> n_cases = <NUM_LIT:3> <EOL> cell_size = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> block_size = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:3> , [ n_cases , <NUM_LIT:1> ] ) <EOL> num_bins = np . random . randint ( <NUM_LIT:7> , <NUM_LIT:9> , [ n_cases , <NUM_LIT:1> ] ) <EOL> channels = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:4> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = MaskedImage ( np . random . randn ( channels [ i , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) ) <EOL> block_size_pixels = cell_size [ i , <NUM_LIT:0> ] * block_size [ i , <NUM_LIT:0> ] <EOL> window_width = np . random . randint ( block_size_pixels , <NUM_LIT> , <NUM_LIT:1> ) <EOL> window_height = np . random . randint ( block_size_pixels , <NUM_LIT> , <NUM_LIT:1> ) <EOL> hog_img = hog ( image , mode = '<STR_LIT>' , algorithm = '<STR_LIT>' , <EOL> cell_size = cell_size [ i , <NUM_LIT:0> ] , block_size = block_size [ i , <NUM_LIT:0> ] , <EOL> num_bins = num_bins [ i , <NUM_LIT:0> ] , window_height = window_height [ <NUM_LIT:0> ] , <EOL> window_width = window_width [ <NUM_LIT:0> ] , window_unit = '<STR_LIT>' , <EOL> window_step_vertical = <NUM_LIT:3> , window_step_horizontal = <NUM_LIT:3> , <EOL> window_step_unit = '<STR_LIT>' , padding = True ) <EOL> length_per_block = block_size [ i , <NUM_LIT:0> ] * block_size [ i , <NUM_LIT:0> ] * num_bins [ i , <NUM_LIT:0> ] <EOL> n_blocks_horizontal = len ( range ( block_size_pixels - <NUM_LIT:1> , window_width [ <NUM_LIT:0> ] , <EOL> cell_size [ i , <NUM_LIT:0> ] ) ) <EOL> n_blocks_vertical = len ( range ( block_size_pixels - <NUM_LIT:1> , window_height [ <NUM_LIT:0> ] , <EOL> cell_size [ i , <NUM_LIT:0> ] ) ) <EOL> n_channels = n_blocks_horizontal * n_blocks_vertical * length_per_block <EOL> assert_allclose ( hog_img . n_channels , n_channels ) <EOL> def test_hog_channels_zhuramanan ( ) : <EOL> n_cases = <NUM_LIT:3> <EOL> cell_size = np . random . randint ( <NUM_LIT:2> , <NUM_LIT:10> , [ n_cases ] ) <EOL> channels = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:4> , [ n_cases ] ) <EOL> for i in range ( n_cases ) : <EOL> image = MaskedImage ( np . random . randn ( channels [ i ] , <NUM_LIT> , <NUM_LIT> ) ) <EOL> win_width = np . random . randint ( <NUM_LIT:3> * cell_size [ i ] , <NUM_LIT> , <NUM_LIT:1> ) <EOL> win_height = np . random . randint ( <NUM_LIT:3> * cell_size [ i ] , <NUM_LIT> , <NUM_LIT:1> ) <EOL> hog_img = hog ( image , mode = '<STR_LIT>' , algorithm = '<STR_LIT>' , <EOL> cell_size = cell_size [ i ] , <EOL> window_height = win_height [ <NUM_LIT:0> ] , <EOL> window_width = win_width [ <NUM_LIT:0> ] , <EOL> window_unit = '<STR_LIT>' , window_step_vertical = <NUM_LIT:3> , <EOL> window_step_horizontal = <NUM_LIT:3> , <EOL> window_step_unit = '<STR_LIT>' , padding = True , verbose = True ) <EOL> length_per_block = <NUM_LIT> <EOL> n_blocks_horizontal = np . floor ( ( win_width [ <NUM_LIT:0> ] / cell_size [ i ] ) + <NUM_LIT:0.5> ) - <NUM_LIT:2> <EOL> n_blocks_vertical = np . floor ( ( win_height [ <NUM_LIT:0> ] / cell_size [ i ] ) + <NUM_LIT:0.5> ) - <NUM_LIT:2> <EOL> n_channels = n_blocks_horizontal * n_blocks_vertical * length_per_block <EOL> assert_allclose ( hog_img . n_channels , n_channels ) <EOL> @ attr ( '<STR_LIT>' ) <EOL> def test_dsift_channels ( ) : <EOL> from menpo . feature import dsift <EOL> n_cases = <NUM_LIT:3> <EOL> num_bins_horizontal = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:3> , [ n_cases , <NUM_LIT:1> ] ) <EOL> num_bins_vertical = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:3> , [ n_cases , <NUM_LIT:1> ] ) <EOL> num_or_bins = np . random . randint ( <NUM_LIT:7> , <NUM_LIT:9> , [ n_cases , <NUM_LIT:1> ] ) <EOL> cell_size_horizontal = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> cell_size_vertical = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> channels = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:4> , [ n_cases ] ) <EOL> for i in range ( n_cases ) : <EOL> image = MaskedImage ( np . random . randn ( channels [ i ] , <NUM_LIT> , <NUM_LIT> ) ) <EOL> dsift_img = dsift ( image , window_step_horizontal = <NUM_LIT:1> , <EOL> window_step_vertical = <NUM_LIT:1> , <EOL> num_bins_horizontal = num_bins_horizontal [ i , <NUM_LIT:0> ] , <EOL> num_bins_vertical = num_bins_vertical [ i , <NUM_LIT:0> ] , <EOL> num_or_bins = num_or_bins [ i , <NUM_LIT:0> ] , <EOL> cell_size_horizontal = cell_size_horizontal [ i , <NUM_LIT:0> ] , <EOL> cell_size_vertical = cell_size_vertical [ i , <NUM_LIT:0> ] ) <EOL> n_channels = ( num_bins_horizontal [ i , <NUM_LIT:0> ] * num_bins_vertical [ i , <NUM_LIT:0> ] * <EOL> num_or_bins [ i , <NUM_LIT:0> ] ) <EOL> assert_allclose ( dsift_img . n_channels , n_channels ) <EOL> def test_lbp_channels ( ) : <EOL> n_cases = <NUM_LIT:3> <EOL> n_combs = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:6> , [ n_cases , <NUM_LIT:1> ] ) <EOL> channels = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:4> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> radius = random . sample ( range ( <NUM_LIT:1> , <NUM_LIT:10> ) , n_combs [ i , <NUM_LIT:0> ] ) <EOL> samples = random . sample ( range ( <NUM_LIT:4> , <NUM_LIT:12> ) , n_combs [ i , <NUM_LIT:0> ] ) <EOL> image = MaskedImage ( np . random . randn ( channels [ i , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) ) <EOL> lbp_img = lbp ( image , radius = radius , samples = samples , <EOL> window_step_vertical = <NUM_LIT:3> , window_step_horizontal = <NUM_LIT:3> , <EOL> window_step_unit = '<STR_LIT>' , padding = True ) <EOL> assert_allclose ( lbp_img . n_channels , n_combs [ i , <NUM_LIT:0> ] * channels [ i , <NUM_LIT:0> ] ) <EOL> def test_igo_channels ( ) : <EOL> n_cases = <NUM_LIT:3> <EOL> channels = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = Image ( np . random . randn ( channels [ i , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) ) <EOL> igo_img = igo ( image ) <EOL> igo2_img = igo ( image , double_angles = True ) <EOL> assert_allclose ( igo_img . shape , image . shape ) <EOL> assert_allclose ( igo2_img . shape , image . shape ) <EOL> assert_allclose ( igo_img . n_channels , <NUM_LIT:2> * channels [ i , <NUM_LIT:0> ] ) <EOL> assert_allclose ( igo2_img . n_channels , <NUM_LIT:4> * channels [ i , <NUM_LIT:0> ] ) <EOL> def test_es_channels ( ) : <EOL> n_cases = <NUM_LIT:3> <EOL> channels = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:10> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = Image ( np . random . randn ( channels [ i , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) ) <EOL> es_img = es ( image ) <EOL> assert_allclose ( es_img . shape , image . shape ) <EOL> assert_allclose ( es_img . n_channels , <NUM_LIT:2> * channels [ i , <NUM_LIT:0> ] ) <EOL> def test_daisy_channels ( ) : <EOL> n_cases = <NUM_LIT:3> <EOL> rings = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:3> , [ n_cases , <NUM_LIT:1> ] ) <EOL> orientations = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:7> , [ n_cases , <NUM_LIT:1> ] ) <EOL> histograms = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:6> , [ n_cases , <NUM_LIT:1> ] ) <EOL> channels = np . random . randint ( <NUM_LIT:1> , <NUM_LIT:5> , [ n_cases , <NUM_LIT:1> ] ) <EOL> for i in range ( n_cases ) : <EOL> image = Image ( np . random . randn ( channels [ i , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) ) <EOL> daisy_img = daisy ( image , step = <NUM_LIT:4> , rings = rings [ i , <NUM_LIT:0> ] , <EOL> orientations = orientations [ i , <NUM_LIT:0> ] , <EOL> histograms = histograms [ i , <NUM_LIT:0> ] ) <EOL> assert_allclose ( daisy_img . shape , ( <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> assert_allclose ( daisy_img . n_channels , <EOL> ( ( rings [ i , <NUM_LIT:0> ] * histograms [ i , <NUM_LIT:0> ] + <NUM_LIT:1> ) * orientations [ i , <NUM_LIT:0> ] ) ) <EOL> def test_igo_values ( ) : <EOL> image = Image ( [ [ <NUM_LIT:1.> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT:1.> ] ] ) <EOL> igo_img = igo ( image ) <EOL> res = np . array ( <EOL> [ [ [ <NUM_LIT> , <NUM_LIT> ] , <EOL> [ - <NUM_LIT> , - <NUM_LIT> ] ] , <EOL> [ [ <NUM_LIT> , - <NUM_LIT> ] , <EOL> [ <NUM_LIT> , - <NUM_LIT> ] ] ] ) <EOL> assert_allclose ( igo_img . pixels , res ) <EOL> image = Image ( [ [ <NUM_LIT:0.> , <NUM_LIT:0.> ] , [ <NUM_LIT:0.> , <NUM_LIT:0.> ] ] ) <EOL> igo_img = igo ( image ) <EOL> res = np . array ( [ [ [ <NUM_LIT:0.> , <NUM_LIT:0.> ] , [ <NUM_LIT:0.> , <NUM_LIT:0.> ] ] , [ [ <NUM_LIT:1.> , <NUM_LIT:1.> ] , [ <NUM_LIT:1.> , <NUM_LIT:1.> ] ] ] ) <EOL> assert_allclose ( igo_img . pixels , res ) <EOL> def test_es_values ( ) : <EOL> image = Image ( [ [ <NUM_LIT:1.> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT:1.> ] ] ) <EOL> es_img = es ( image ) <EOL> k = <NUM_LIT:1.0> / ( <NUM_LIT:2> * ( <NUM_LIT:2> ** <NUM_LIT:0.5> ) ) <EOL> res = np . array ( [ [ [ k , - k ] , [ k , - k ] ] , [ [ k , k ] , [ - k , - k ] ] ] ) <EOL> assert_allclose ( es_img . pixels , res ) <EOL> def test_daisy_values ( ) : <EOL> image = Image ( [ [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> daisy_img = daisy ( image , step = <NUM_LIT:1> , rings = <NUM_LIT:2> , radius = <NUM_LIT:1> , orientations = <NUM_LIT:8> , <EOL> histograms = <NUM_LIT:8> ) <EOL> assert_allclose ( np . around ( daisy_img . pixels [ <NUM_LIT:10> , <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:6> ) , <NUM_LIT> ) <EOL> assert_allclose ( np . around ( daisy_img . pixels [ <NUM_LIT:20> , <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:6> ) , <NUM_LIT> ) <EOL> assert_allclose ( np . around ( daisy_img . pixels [ <NUM_LIT:30> , <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:6> ) , <NUM_LIT> ) <EOL> assert_allclose ( np . around ( daisy_img . pixels [ <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:6> ) , <NUM_LIT> ) <EOL> @ attr ( '<STR_LIT>' ) <EOL> def test_dsift_values ( ) : <EOL> from menpo . feature import dsift <EOL> image = Image ( [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] , [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> ] , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] , [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> ] ] ) <EOL> sift_img = dsift ( image , cell_size_horizontal = <NUM_LIT:2> , cell_size_vertical = <NUM_LIT:2> ) <EOL> assert_allclose ( np . around ( sift_img . pixels [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:6> ) , <NUM_LIT> , <EOL> rtol = <NUM_LIT> ) <EOL> assert_allclose ( np . around ( sift_img . pixels [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:6> ) , <NUM_LIT> , <EOL> rtol = <NUM_LIT> ) <EOL> assert_allclose ( np . around ( sift_img . pixels [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ] , <NUM_LIT:6> ) , <NUM_LIT> , <EOL> rtol = <NUM_LIT> ) <EOL> assert_allclose ( np . around ( sift_img . pixels [ <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:6> ) , <NUM_LIT> , <EOL> rtol = <NUM_LIT> ) <EOL> assert <NUM_LIT:1> <EOL> def test_lbp_values ( ) : <EOL> image = Image ( [ [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] ] ) <EOL> lbp_img = lbp ( image , radius = <NUM_LIT:1> , samples = <NUM_LIT:4> , mapping_type = '<STR_LIT:none>' , <EOL> padding = False ) <EOL> assert_allclose ( lbp_img . pixels , <NUM_LIT> ) <EOL> image = Image ( [ [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] ] ) <EOL> lbp_img = lbp ( image , radius = <NUM_LIT:1> , samples = <NUM_LIT:4> , mapping_type = '<STR_LIT>' , <EOL> padding = False ) <EOL> assert_allclose ( lbp_img . pixels , <NUM_LIT:0.> ) <EOL> image = Image ( [ [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] ] ) <EOL> lbp_img = lbp ( image , radius = <NUM_LIT:1> , samples = <NUM_LIT:4> , mapping_type = '<STR_LIT>' , padding = False ) <EOL> assert_allclose ( lbp_img . pixels , <NUM_LIT> ) <EOL> image = Image ( [ [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT:0.> ] ] ) <EOL> lbp_img = lbp ( image , radius = <NUM_LIT:1> , samples = <NUM_LIT:4> , mapping_type = '<STR_LIT>' , padding = False ) <EOL> assert_allclose ( lbp_img . pixels , <NUM_LIT> ) <EOL> def test_constrain_landmarks ( ) : <EOL> breaking_bad = mio . import_builtin_asset ( '<STR_LIT>' ) . as_masked ( ) <EOL> breaking_bad = breaking_bad . crop_to_landmarks ( boundary = <NUM_LIT:20> ) <EOL> breaking_bad = breaking_bad . resize ( [ <NUM_LIT:50> , <NUM_LIT:50> ] ) <EOL> breaking_bad . constrain_mask_to_landmarks ( ) <EOL> hog_b = hog ( breaking_bad , mode = '<STR_LIT>' ) <EOL> x = np . where ( hog_b . landmarks [ '<STR_LIT>' ] . lms . points [ : , <NUM_LIT:0> ] > hog_b . shape [ <NUM_LIT:1> ] - <NUM_LIT:1> ) <EOL> y = np . where ( hog_b . landmarks [ '<STR_LIT>' ] . lms . points [ : , <NUM_LIT:0> ] > hog_b . shape [ <NUM_LIT:0> ] - <NUM_LIT:1> ) <EOL> assert_allclose ( len ( x [ <NUM_LIT:0> ] ) + len ( y [ <NUM_LIT:0> ] ) , <NUM_LIT:12> ) <EOL> hog_b = hog ( breaking_bad , mode = '<STR_LIT>' ) <EOL> hog_b . constrain_landmarks_to_bounds ( ) <EOL> x = np . where ( hog_b . landmarks [ '<STR_LIT>' ] . lms . points [ : , <NUM_LIT:0> ] > hog_b . shape [ <NUM_LIT:1> ] - <NUM_LIT:1> ) <EOL> y = np . where ( hog_b . landmarks [ '<STR_LIT>' ] . lms . points [ : , <NUM_LIT:0> ] > hog_b . shape [ <NUM_LIT:0> ] - <NUM_LIT:1> ) <EOL> assert_allclose ( len ( x [ <NUM_LIT:0> ] ) + len ( y [ <NUM_LIT:0> ] ) , <NUM_LIT:0> ) </s>
